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])
|