Skip to content

Instantly share code, notes, and snippets.

@tancnle
Created August 3, 2017 23:34
Show Gist options
  • Save tancnle/389eb9adea2dc996fae4e4e5612d64bf to your computer and use it in GitHub Desktop.
Save tancnle/389eb9adea2dc996fae4e4e5612d64bf to your computer and use it in GitHub Desktop.
SHA1 vs MD5 bechmark
import hashlib
import pytest
foo = b'The lazy fox jumps over the running dogs'
def test_sha1(benchmark):
sha1 = hashlib.sha1()
sha1.update(foo)
benchmark(sha1.hexdigest)
def test_md5(benchmark):
md5 = hashlib.md5()
md5.update(foo)
benchmark(md5.hexdigest)
@jeffreytheobald
Copy link

Very cool!

@waichee
Copy link

waichee commented Aug 3, 2017

what is the benchmark object? or is that from python library?

@tancnle
Copy link
Author

tancnle commented Aug 4, 2017

Oh it's pytest-benchmark @waichee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment