Skip to content

test: add optional pytest-benchmark suite for core operations - #54

Open
acul71 wants to merge 1 commit into
masterfrom
issue-45
Open

test: add optional pytest-benchmark suite for core operations#54
acul71 wants to merge 1 commit into
masterfrom
issue-45

Conversation

@acul71

@acul71 acul71 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #45.

  • Add pytest-benchmark to [project.optional-dependencies].dev
  • Add tests/test_benchmarks.py for Code, tag, prefix encode/decode, and known_codes
  • Benchmarks are opt-in (--benchmark-only); not required in default CI tox core beyond collecting tests
  • Add newsfragment 45.performance.rst

Demo

.......                                                                  [100%]

------------------------------------------------------------------------------------------------- benchmark: 7 tests ------------------------------------------------------------------------------------------------
Name (time in ns)                       Min                    Max                  Mean              StdDev                Median                IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_bench_known_codes              62.9807 (1.0)       2,497.9818 (1.92)        73.8960 (1.0)       26.6111 (2.99)        71.0133 (1.0)       3.9581 (1.54)     620;1867   13,532.5237 (1.0)       16302           1
test_bench_code_construction        71.0315 (1.13)      1,399.3431 (1.08)        82.9965 (1.12)       8.8988 (1.0)         82.2201 (1.16)      2.5630 (1.0)    6595;12490   12,048.6981 (0.89)     199759          32
test_bench_extract_prefix          163.3106 (2.59)      1,301.0697 (1.0)        177.3419 (2.40)       9.0994 (1.02)       176.2428 (2.48)      5.1383 (2.00)    8177;6817    5,638.8238 (0.42)     194479          29
test_bench_get_codec               227.9994 (3.62)      3,490.0149 (2.68)       259.4296 (3.51)      43.3151 (4.87)       256.9868 (3.62)     23.0502 (8.99)    4195;4518    3,854.6102 (0.28)     157705           1
test_bench_add_prefix              249.0124 (3.95)     18,149.0323 (13.95)      277.9969 (3.76)      65.9678 (7.41)       273.9835 (3.86)     16.9966 (6.63)     851;9170    3,597.1618 (0.27)     174795           1
test_bench_code_from_string        582.0184 (9.24)      5,316.9788 (4.09)       642.5564 (8.70)      71.0837 (7.99)       636.0351 (8.96)     33.0037 (12.88)   3004;4775    1,556.2836 (0.12)     191646           1
test_bench_code_tag              1,075.9686 (17.08)    10,920.9795 (8.39)     1,200.6378 (16.25)    102.9081 (11.56)    1,191.9765 (16.79)    44.9363 (17.53)   2260;3860      832.8907 (0.06)     130056           1
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
7 passed in 2.81s

Test plan

  • make lint / typecheck / test / docs-ci locally
  • Newsfragment 45.performance.rst present
  • CI green on this PR
  • Review requested from @sumanjeet0012

Made with Cursor

Closes #45.

Co-authored-by: Cursor <cursoragent@cursor.com>
@acul71

acul71 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@sumanjeet0012 Could you please review this PR when you have a chance? Thanks!

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.

Add benchmark tests for core operations

1 participant