multiformats / multiformats/py-multibase
No benchmark tests for encode/decode operations
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 25
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
There are no benchmark tests for encode/decode operations. go-multibase includes BenchmarkEncode, BenchmarkDecode, and BenchmarkRoundTrip for every encoding, which help catch performance regressions.
Problem
The test suite has functional tests but zero benchmarks. Operations like base58 encoding (which involves big-integer arithmetic) and base256emoji encoding (which involves UTF-8 encoding) have no performance baseline.
go-multibase benchmarks every encoding:
func BenchmarkEncode(b *testing.B) {
for _, name := range benchmarkCodecs {
b.Run(name, func(b *testing.B) {
base := Encodings[name]
for i := 0; i < b.N; i++ {
Encode(base, benchmarkBuf[:])
}
})
}
}
Proposed Solution
-
Install
pytest-benchmarkas a dev dependency. -
Create
tests/test_benchmarks.py:import pytest from multibase import encode, decode, ENCODINGS BENCH_DATA = b"Decentralize everything!!!" @pytest.mark.benchmark @pytest.mark.parametrize("encoding_info", ENCODINGS, ids=lambda e: e.encoding) def test_bench_encode(benchmark, encoding_info): benchmark(encode, encoding_info.encoding, BENCH_DATA) @pytest.mark.benchmark @pytest.mark.parametrize("encoding_info", ENCODINGS, ids=lambda e: e.encoding) def test_bench_decode(benchmark, encoding_info): encoded = encode(encoding_info.encoding, BENCH_DATA) benchmark(decode, encoded) @pytest.mark.benchmark @pytest.mark.parametrize("encoding_info", ENCODINGS, ids=lambda e: e.encoding) def test_bench_roundtrip(benchmark, encoding_info): def roundtrip(): return decode(encode(encoding_info.encoding, BENCH_DATA)) benchmark(roundtrip)
Related
- Go benchmarks: go-multibase
multibase_test.goBenchmarkEncode,BenchmarkDecode,BenchmarkRoundTrip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Create tests/test_benchmarks.py using pytest-benchmark and the existing multibase.encode, decode, and ENCODINGS APIs. Add parametrized encode, decode, and round-trip benchmarks with the proposed benchmark data, and install pytest-benchmark as a development dependency. Done means every encoding has all three benchmark cases and the benchmark tests run successfully.
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
- 75/100