Skip to content

Instantly share code, notes, and snippets.

@bmbouter
bmbouter / time_hashers.py
Created September 5, 2024 08:04
A script to measure the `update()` and `hexdigest()` calls when computing multiple hashers
import hashlib
import os
import time
# Function to generate a large binary data set (e.g., 100 MB)
def generate_large_binary_data(size_in_mb):
# Generate random binary data of the specified size
return os.urandom(size_in_mb * 1024 * 1024) # Convert MB to bytes
# Function to compute multiple hashes from the same data input and measure time per hasher