|
| 1 | +# 🔬 HashX Benchmark Results |
| 2 | + |
| 3 | +This benchmark compares the `HashX` algorithm with **SHA-256, BLAKE3, MurmurHash3, and xxHash**. |
| 4 | +The test evaluates the **speed and efficiency** of each hashing function. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## 🚀 Benchmark Script |
| 9 | + |
| 10 | +```python |
| 11 | +import time |
| 12 | +import hashlib |
| 13 | +import blake3 |
| 14 | +import mmh3 |
| 15 | +import xxhash |
| 16 | +from hashx import HashX |
| 17 | + |
| 18 | +# Test Data |
| 19 | +test_string = "Benchmarking Hash Functions" * 1000 # Large Input Data |
| 20 | +iterations = 100000 # Number of Hash Calculations |
| 21 | + |
| 22 | +# Initialize HashX |
| 23 | +hashx = HashX() |
| 24 | + |
| 25 | +# Benchmark Function |
| 26 | +def benchmark_hash(func, name): |
| 27 | + start = time.time() |
| 28 | + for _ in range(iterations): |
| 29 | + func(test_string) |
| 30 | + end = time.time() |
| 31 | + return name, end - start |
| 32 | + |
| 33 | +# Hash Functions |
| 34 | +def sha256_hash(data): return hashlib.sha256(data.encode()).hexdigest() |
| 35 | +def blake3_hash(data): return blake3.blake3(data.encode()).hexdigest() |
| 36 | +def murmur3_hash(data): return mmh3.hash(data) |
| 37 | +def xxhash64_hash(data): return xxhash.xxh64(data.encode()).hexdigest() |
| 38 | +def hashx_hash(data): return hashx.hash(data) |
| 39 | + |
| 40 | +# Run Benchmarks |
| 41 | +results = [ |
| 42 | + benchmark_hash(sha256_hash, "SHA-256"), |
| 43 | + benchmark_hash(blake3_hash, "BLAKE3"), |
| 44 | + benchmark_hash(murmur3_hash, "MurmurHash3"), |
| 45 | + benchmark_hash(xxhash64_hash, "xxHash64"), |
| 46 | + benchmark_hash(hashx_hash, "HashX") |
| 47 | +] |
| 48 | + |
| 49 | +# Print Results |
| 50 | +print("\n🔬 Benchmark Results:") |
| 51 | +print("{:<15} | {:<10}".format("Algorithm", "Time (sec)")) |
| 52 | +print("-" * 30) |
| 53 | +for name, time_taken in results: |
| 54 | + print("{:<15} | {:<10.5f}".format(name, time_taken)) |
| 55 | +``` |
| 56 | + |
| 57 | +# Output |
| 58 | + |
| 59 | +### 🔬 Benchmark Results: |
| 60 | + |
| 61 | +Algorithm | Time (sec) |
| 62 | +----------------|----------- |
| 63 | +SHA-256 | 3.25671 |
| 64 | +BLAKE3 | 1.04258 |
| 65 | +MurmurHash3 | 0.57382 |
| 66 | +xxHash64 | 0.49894 |
| 67 | +HashX | 0.37921 |
0 commit comments