File: perf.jl

package info (click to toggle)
julia 1.0.3%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,452 kB
  • sloc: lisp: 236,453; ansic: 55,579; cpp: 25,603; makefile: 1,685; pascal: 1,130; sh: 956; asm: 86; xml: 76
file content (47 lines) | stat: -rw-r--r-- 810 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This file is a part of Julia. License is MIT: https://julialang.org/license

using SHA

if isempty(ARGS)
    error("need file to test sha perf")
elseif !isfile(ARGS[1])
    error("file $(ARGS[1]) does not exist")
end


function do_tests(filepath)
    # test performance
    print("read:    ")
    @time begin
        fh = open(filepath, "r")
        bytes = read(fh)
    end
    GC.gc()

    print("SHA-1:   ")
    sha1(bytes)
    GC.gc()
    @time sha1(bytes)

    print("SHA2-256: ")
    sha256(bytes)
    GC.gc()
    @time sha256(bytes)

    print("SHA2-512: ")
    sha512(bytes)
    GC.gc()
    @time sha512(bytes)

    print("SHA3-256: ")
    sha3_256(bytes)
    GC.gc()
    @time sha3_256(bytes)

    print("SHA3-512: ")
    sha3_512(bytes)
    GC.gc()
    @time sha3_512(bytes)
end

do_tests(ARGS[1])