Created
May 1, 2023 23:20
-
-
Save nfl0/b4259c0c072372477c0a1f5a5cae9bd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from blake3 import blake3 | |
import hashlib | |
# Data for benchmarking | |
data = b"some data to hash" * 1000000 | |
# BLAKE3 hashing and benchmarking | |
start_time_blake3 = time.time() | |
hasher_blake3 = blake3() | |
hasher_blake3.update(data) | |
hash_digest_blake3 = hasher_blake3.digest() | |
end_time_blake3 = time.time() | |
# SHA256 hashing and benchmarking | |
start_time_sha256 = time.time() | |
hasher_sha256 = hashlib.sha256() | |
hasher_sha256.update(data) | |
hash_digest_sha256 = hasher_sha256.digest() | |
end_time_sha256 = time.time() | |
# Results | |
print("BLAKE3 hash:", hash_digest_blake3.hex()) | |
print("SHA256 hash:", hash_digest_sha256.hex()) | |
print("BLAKE3 time: {:.6f} seconds".format(end_time_blake3 - start_time_blake3)) | |
print("SHA256 time: {:.6f} seconds".format(end_time_sha256 - start_time_sha256)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment