Skip to content

Add CodSpeed continuous benchmarking - #19

Merged
youknowone merged 1 commit into
mainfrom
codspeed-wizard-1788067709231
Aug 30, 2026
Merged

Add CodSpeed continuous benchmarking#19
youknowone merged 1 commit into
mainfrom
codspeed-wizard-1788067709231

Conversation

@codspeed-hq

@codspeed-hq codspeed-hq Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

This sets up continuous performance measurement for pymath with CodSpeed.

What was added

Benchmark harness (divan via codspeed-divan-compat)

codspeed-divan-compat is added as a dev-dependency renamed to divan, so the benchmarks are plain divan benchmarks: they run standalone locally and are instrumented automatically when executed through CodSpeed.

Three benchmark suites in benches/:

  • math.rs — real-valued functions, grouped by source module:
    • trigonometric: sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh, asinh, acosh, atanh
    • exponential: exp, exp2, expm1, log (natural and with an explicit base), log2, log10, log1p, sqrt, cbrt, pow
    • gamma: erf, erfc (including the |x| > 1.5 continued-fraction branch), gamma for positive and negative arguments, lgamma
    • misc: fabs, floor/ceil/trunc, frexp/modf, fmod, remainder, fma, nextafter with steps, ldexp/ulp, isclose
    • aggregate: fsum, dist, sumprod, sumprod_int, prod at 8 / 128 / 4096 elements to cover both the short and long reduction paths
  • cmath.rs — complex functions (exp, log, log10, sqrt, the six trigonometric and six hyperbolic functions plus their inverses, abs/phase, polar/rect) over a spiral of inputs spanning all four quadrants
  • integer.rs — big-integer functions (factorial, comb, perm, isqrt, gcd, lcm, log_bigint) at several magnitudes, gated behind required-features = ["num-bigint"]

Each scalar benchmark sweeps a fixed set of representative finite inputs inside the measured closure, so results reflect the function under test rather than harness overhead, and the input domains are chosen to stay in the valid range of each function.

CI workflow.github/workflows/codspeed.yml runs the benchmarks in CPU simulation mode on ubuntu-latest (same runner as the existing Rust workflow), on pushes to main, on pull requests, and on workflow_dispatch so CodSpeed can backfill baseline data. It authenticates with OIDC (id-token: write), builds with cargo codspeed build --features num-bigint so all three suites are included, and Python is set up because the crate's dev-dependencies include pyo3 with auto-initialize.

README — added the CodSpeed badge.

Validation

All three suites were built and executed locally with codspeed run --mode simulation -- cargo codspeed run; the full set of benchmarks completed and reported results. cargo clippy --benches --features num-bigint and cargo fmt are clean.

Next steps

  • Merge this PR so the first main run establishes the performance baseline.
  • Subsequent pull requests will get a CodSpeed report comparing against that baseline.
  • New functions ported from CPython can be covered by adding them to the corresponding module in benches/.

@codspeed-hq

codspeed-hq Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Congrats! CodSpeed is installed 🎉

🆕 95 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks


ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Open in CodSpeed

@codspeed-hq
codspeed-hq Bot marked this pull request as ready for review August 30, 2026 05:36
@codspeed-hq
codspeed-hq Bot requested a review from youknowone August 30, 2026 05:37
@youknowone
youknowone merged commit 22df58a into main Aug 30, 2026
7 checks passed
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.

2 participants