File: perf.jl

package info (click to toggle)
julia 1.5.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 91,132 kB
  • sloc: lisp: 278,486; ansic: 60,186; cpp: 29,801; sh: 2,403; makefile: 1,998; pascal: 1,313; objc: 647; javascript: 516; asm: 226; python: 161; xml: 34
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])