Skip to content

Instantly share code, notes, and snippets.

@cgoldberg
Last active December 5, 2025 20:36
Show Gist options
  • Select an option

  • Save cgoldberg/9b75bd3c1af40bd51d76b365a19be410 to your computer and use it in GitHub Desktop.

Select an option

Save cgoldberg/9b75bd3c1af40bd51d76b365a19be410 to your computer and use it in GitHub Desktop.
Python SHA512 Benchmark

super simple hash benchmark


  • run a loop a half million times:
    • split a delimited string into 5 fields
    • strip invalid characters from each field with a regex
    • calculate a SHA3-512 hash and get the digest for each field (2.5 million hashes)

Environment:

  • OS: Windows 11
  • Runtime: Python 3.14
  • CPU: 11th Gen Intel Core i7-1185G7 @ 3.0GHz

Results:

$ time python ./hash_test.py

real    0m45.129s
user    0m0.015s
sys     0m0.000s
import re
from Crypto.Hash import SHA3_512 # pycryptodome
ITERATIONS = 500000
if __name__ == "__main__":
record = "First Name (&#*First Name (&#*First Name (&#*First Name (&#*First Name (&#"
for _ in range(ITERATIONS):
fields = record.split("*")
for field in fields:
s = re.sub(r"[^0-9a-zA-Z]+", "", field)
sha3_hash = SHA3_512.new()
sha3_hash.update(s.encode())
digest = sha3_hash.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment