Skip to content

Add codec and Block encode/decode benchmarks - #59

Merged
acul71 merged 2 commits into
masterfrom
fix/34-benchmarks
Nov 20, 2026
Merged

acul71 merged 2 commits into
masterfrom
fix/34-benchmarks

Conversation

@acul71

@acul71 acul71 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #34

Summary

  • Add pytest-benchmark to the test dependency group and register the benchmark marker.
  • Add tests/test_benchmarks.py for DAG-CBOR, DAG-JSON, DAG-PB, raw encode/decode plus Block.encode / Block.decode.
  • Document running benches in docs/contributing.rst; newsfragment 34.performance.rst.

Test plan

  • make lint / make typecheck / make test / make docs-ci locally
  • CI green

Made with Cursor

acul71 and others added 2 commits November 20, 2026 01:47
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@acul71
acul71 merged commit 1090b4d into master Nov 20, 2026
22 checks passed
@acul71
acul71 deleted the fix/34-benchmarks branch November 20, 2026 00:54
@acul71

acul71 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Local benchmark results (corrected)

Ran pytest -m benchmark after merge on master (tiny fixed payloads).

Name (time in ns)                     Min                     Max                  Mean              StdDev                Median                 IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_bench_raw_decode             27.8512 (1.0)        2,013.5119 (2.22)        30.2021 (1.0)        5.3632 (1.15)        29.3036 (1.0)        1.7738 (1.21)    4231;9504   33,110.2755 (1.0)      199840         168
test_bench_raw_encode             65.8600 (2.36)         906.6600 (1.0)         69.7327 (2.31)       4.6453 (1.0)         68.2900 (2.33)       1.4700 (1.0)    20130;22275   14,340.4807 (0.43)     130481         100
test_bench_dag_pb_decode         385.0000 (13.82)     13,049.9975 (14.39)      451.7270 (14.96)     66.9789 (14.42)      444.0008 (15.15)     33.0037 (22.45)   4146;5326    2,213.7263 (0.07)     143042           1
test_bench_dag_pb_encode         649.9977 (23.34)     19,015.0022 (20.97)      755.9868 (25.03)    151.8487 (32.69)      729.9968 (24.91)     59.9975 (40.81)   2302;4395    1,322.7745 (0.04)      76924           1
test_bench_dag_cbor_decode     1,126.9949 (40.46)     44,668.9955 (49.27)    1,261.6629 (41.77)    210.6672 (45.35)    1,237.9969 (42.25)     59.0007 (40.14)   1279;6435      792.6047 (0.02)      81560           1
test_bench_dag_json_decode     1,332.9991 (47.86)    112,393.0051 (123.96)   1,472.7106 (48.76)    551.1565 (118.65)   1,441.9929 (49.21)     59.0007 (40.14)    510;4802      679.0200 (0.02)      45174           1
test_bench_dag_json_encode     2,315.0060 (83.12)     15,778.0014 (17.40)    2,550.0290 (84.43)    237.2051 (51.06)    2,496.9995 (85.21)    111.9988 (76.19)   3130;4922      392.1524 (0.01)      43244           1
test_bench_block_decode        3,098.9977 (111.27)    31,109.0043 (34.31)    3,557.8204 (117.80)   384.2839 (82.73)    3,477.9951 (118.69)   324.0057 (220.41)   2620;909      281.0710 (0.01)      35141           1
test_bench_dag_cbor_encode     3,627.9962 (130.26)    47,898.9969 (52.83)    4,040.4680 (133.78)   389.5999 (83.87)    3,945.0024 (134.63)   184.0017 (125.17)  2763;5313      247.4961 (0.01)      36984           1
test_bench_block_encode        5,874.0043 (210.91)    19,283.9943 (21.27)    6,587.8389 (218.13)   455.6241 (98.08)    6,465.0012 (220.62)   336.2584 (228.74)  2147;1370      151.7948 (0.00)      13545           1
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

10 passed. Microbenchmarks for regression detection (not large-block throughput). Relative order: raw ≫ PB ≫ CBOR/JSON decode ≫ Block (hash+CID).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No benchmark tests

1 participant