multiformats / multiformats/py-multihash

No benchmark tests for `sum()`, `encode()`, `decode()` operations

Open Beginner friendly
#54 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
17
Forks
17
Avg merge
1h 5m
Merged PRs (30d)
3

Description

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
  1. Install pytest-benchmark as a dev dependency.

  2. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Add pytest-benchmark as a development dependency, then create tests/test_benchmarks.py with the benchmark cases and parameters shown in the issue. Start by checking the existing test and dependency setup, then run the benchmark-marked tests. Done means sum(), encode(), decode(), and the listed hash variants have repeatable benchmark coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance, testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.