There are no benchmark tests. go-multihash includes BenchmarkSum, BenchmarkEncode, BenchmarkDecode, BenchmarkBlake2B, and BenchmarkSumAllLarge which help catch performance regressions.
Problem
The test suite has functional tests but zero benchmarks. Operations like Blake2b hashing (which has 64 variants) and SHAKE variable-length hashing have no performance baseline.
Proposed Solution
-
Install pytest-benchmark as a dev dependency.
-
Create tests/test_benchmarks.py:
import pytest
from multihash import sum, encode, decode, Func
BENCH_DATA = b"benchmark test data for multihash operations" * 100
@pytest.mark.benchmark
def test_bench_sum_sha256(benchmark):
benchmark(sum, BENCH_DATA, Func.sha2_256)
@pytest.mark.benchmark
def test_bench_sum_sha512(benchmark):
benchmark(sum, BENCH_DATA, Func.sha2_512)
@pytest.mark.benchmark
def test_bench_sum_blake3(benchmark):
benchmark(sum, BENCH_DATA, Func.blake3)
@pytest.mark.benchmark
@pytest.mark.parametrize("bits", [8, 128, 256, 384, 512])
def test_bench_sum_blake2b(benchmark, bits):
func = getattr(Func, f"blake2b_{bits}")
benchmark(sum, BENCH_DATA, func)
@pytest.mark.benchmark
def test_bench_encode(benchmark):
digest = sum(BENCH_DATA, Func.sha2_256)
benchmark(digest.encode)
@pytest.mark.benchmark
def test_bench_decode(benchmark):
encoded = sum(BENCH_DATA, Func.sha2_256).encode()
benchmark(decode, encoded)
Related
There are no benchmark tests. go-multihash includes
BenchmarkSum,BenchmarkEncode,BenchmarkDecode,BenchmarkBlake2B, andBenchmarkSumAllLargewhich help catch performance regressions.Problem
The test suite has functional tests but zero benchmarks. Operations like Blake2b hashing (which has 64 variants) and SHAKE variable-length hashing have no performance baseline.
Proposed Solution
Install
pytest-benchmarkas a dev dependency.Create
tests/test_benchmarks.py:Related
sum_test.go,multihash_test.go