ipld / ipld/py-ipld-dag

No benchmark tests

Open Beginner friendly
#34 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
13
Forks
9
PR merge metrics
No merged PRs in 30d

Description

There are no benchmark tests for codec encode/decode operations. This makes it difficult to detect performance regressions.

### Proposed Solution

Add `tests/test_benchmarks.py`:

```python
import pytest
from dag import Block
from dag.codecs import dag_cbor, dag_json, dag_pb, raw

BENCH_DATA = {"key": "value", "number": 42, "list": [1, 2, 3]}
BENCH_BYTES = dag_cbor.encode(BENCH_DATA)

@pytest.mark.benchmark
def test_bench_dag_cbor_encode(benchmark):
benchmark(dag_cbor.encode, BENCH_DATA)

@pytest.mark.benchmark
def test_bench_dag_cbor_decode(benchmark):
benchmark(dag_cbor.decode, BENCH_BYTES)

@pytest.mark.benchmark
def test_bench_dag_json_encode(benchmark):
benchmark(dag_json.encode, BENCH_DATA)

@pytest.mark.benchmark
def test_bench_dag_json_decode(benchmark):
benchmark(dag_json.decode, dag_json.encode(BENCH_DATA))

@pytest.mark.benchmark
def test_bench_block_encode(benchmark):
benchmark(Block.encode, value=BENCH_DATA, codec=dag_cbor.codec)

@pytest.mark.benchmark
def test_bench_block_decode(benchmark):
benchmark(Block.decode, data=BENCH_BYTES, codec=dag_cbor.codec)
```

### Related

- Dev dependency to add: `pytest-benchmark`

Contributor guide

Open the contributing guide

Research direction

Start with the proposed tests/test_benchmarks.py and review the existing codec and Block APIs used by the benchmark examples. Add the pytest-benchmark development dependency, implement benchmarks for the listed encode/decode operations, and run the benchmark tests to confirm they execute successfully.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.