Skip to content

Instantly share code, notes, and snippets.

@epignatelli
Last active April 2, 2020 12:40
Show Gist options
  • Select an option

  • Save epignatelli/75cf84b1534a1e817ea36004dfd52e6a to your computer and use it in GitHub Desktop.

Select an option

Save epignatelli/75cf84b1534a1e817ea36004dfd52e6a to your computer and use it in GitHub Desktop.
Testing the performance of different hashing algorithms for hashing a numpy array
import hashlib
funcs = [
hashlib.blake2b,
hashlib.blake2s,
hashlib.md5,
hashlib.sha1,
hashlib.sha224,
hashlib.sha256,
hashlib.sha256,
hashlib.sha384
]
for func in funcs:
%timeit -n100 func(np.ones((1024, 1024))).hexdigest()
# 16.2 ms ± 372 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
# 19.3 ms ± 70.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
# 14.1 ms ± 52.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
# 10.2 ms ± 47.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
# 21.9 ms ± 392 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
# 22.3 ms ± 452 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
# 21.7 ms ± 204 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
# 15 ms ± 36.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment