Speed comparison of murmurhash3, md5 and sha1

I was worried about the speed of the hash function, so make a note.

Compare the classic (?) Md5 with sha1 and murmurhash3. Execute 100 sets of 100,000 times each and compare the results. The machine I ran was a MacBook Pro Late 2016 with an Intel Core i7 2.6GHz Quad Core.

Hash function time(s)
md5 12.7691998482
sha1 13.9324979782
murmurhash3 2.75016593933

This is the code for comparison.

#!/usr/bin/env python
import timeit


def mmh3_test():
  import mmh3

  for i in range(0, 100000):
    mmh3.hash(str(i))


def md5_test():
  import hashlib

  for i in range(0, 100000):
    hashlib.md5(str(i)).hexdigest()


def sha1_test():
  import hashlib

  for i in range(0, 100000):
    hashlib.sha1(str(i)).hexdigest()


if __name__ == '__main__':
  import timeit
  print(timeit.timeit("mmh3_test()", setup="from __main__ import mmh3_test", number=100))
  print(timeit.timeit("md5_test()", setup="from __main__ import md5_test", number=100))
  print(timeit.timeit("sha1_test()", setup="from __main__ import sha1_test", number=100))

Recommended Posts

Speed comparison of murmurhash3, md5 and sha1
Comparison of Apex and Lamvery
Speed comparison between CPython and PyPy
Speed comparison of Python XML parsing
Speed comparison of Wiktionary full text processing with F # and Python
Story of speed comparison of sort of numerical value and character string (unfinished))
Comparison of gem, bundler and pip, venv
Comparison of class inheritance and constructor description
Try speed comparison of BigQuery Storage API
Comparison of L1 regularization and Leaky Relu
[Python3] Coarse graining of numpy.ndarray Speed comparison etc.
Comparison of k-means implementation examples of scikit-learn and pyclustering
Compare the speed of Python append and map
Comparison of R and Python writing (Euclidean algorithm)
Comparison of Python and Ruby (Environment / Grammar / Literal)
Speed comparison between incrementing count variable and enumerate
What to use for Python stacks and queues (speed comparison of each data structure)
Speed comparison of each language by Monte Carlo method
File write speed comparison experiment between python 2.7.9 and pypy 2.5.0
Image capture / OpenCV speed comparison with and without GPU
A quick comparison of Python and node.js test libraries
DNN (Deep Learning) Library: Comparison of chainer and TensorFlow (1)
Comparison of Windows Server and Free Linux to Commercial Linux
Comparison table of frequently used processes of Python and Clojure
Comparison of CoffeeScript with JavaScript, Python and Ruby grammar
Comparison of LDA implementations
Comparison of online classifiers
Comparison of fitting programs
Now "average of sums from 1 to 10" and its execution speed
[Python] How to set variable names dynamically and speed comparison
Comparison of how to use higher-order functions in Python 2 and 3
BASIC and C and assembler speed comparison and optimization play with IchigoJam
Comparison of Hungarian law and general-purpose solver for allocation problems