Repository navigation
feat(benchmarking): add @sourceloop/benchmarking package - #2613
Merged
Merged
Conversation
sf-sahil-jassal
force-pushed
the
feat/benchmarking-package
branch
3 times, most recently
from
September 22, 2026 13:35
a4cf539 to
3af9248
Compare
akshatdubeysf
requested changes
Sep 23, 2026
sf-sahil-jassal
force-pushed
the
feat/benchmarking-package
branch
from
September 24, 2026 01:52
3af9248 to
6fafe2b
Compare
Add a package that lets a team write throughput benchmarks as Mocha tests, and fail the build when a change makes an operation slower. The package gives bench.describe() and bench.it(), which wrap tinybench. Each run keeps its throughput mean in a committed JSON file. The gate compares the current run against the average of the last ten runs, and fails the test when the drop is more than the threshold. Two rules differ from the usual tools. A regressed run is not added to the history, so a bad merge cannot move the baseline down. And a new benchmark records samples quietly until it has enough of them, because a comparison against one prior run is not a signal. The README gives the full settings list, the rules the gate uses, and examples of good and bad benchmarks.
sf-sahil-jassal
force-pushed
the
feat/benchmarking-package
branch
from
September 24, 2026 01:55
6fafe2b to
cb05f05
Compare
akshatdubeysf
approved these changes
Sep 29, 2026
piyushsinghgaur1
approved these changes
Sep 29, 2026
a-ganguly
reviewed
Sep 29, 2026
a-ganguly
reviewed
Sep 29, 2026
a-ganguly
reviewed
Sep 29, 2026
a-ganguly
reviewed
Sep 29, 2026
a-ganguly
reviewed
Sep 29, 2026
Treat non-object baseline files as corrupt. Drop non-finite history entries. Report the stored run count. Align engines and @types/node with 22 || 24.
|
a-ganguly
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Adds
@sourceloop/benchmarking, a package that lets a team write throughput benchmarks as Mocha tests and fail the build when a change makes an operation slower.bench.describe()andbench.it()wrap tinybench. Each run records its throughput mean in a committed JSON file. The gate compares the current run against the average of the last ten runs and fails the test when the drop is larger than the threshold.Two rules differ from what bencher, github-action-benchmark and CodSpeed do, and the README says so plainly:
The package is ported from an internal
perf-testingpackage that is already in use. Behaviour matches it, except for the renamed environment variables (PERF_*toBENCH_*), the renamed helpers (pit/pdescribetobench.it/bench.describe), the new minimum sample count, and stricter parsing of numeric settings.Documentation lives in
packages/benchmarking/README.md. Besides the settings table and the rules the gate applies, it covers how to write a benchmark that means something: good and bad examples side by side, why aPromise.allbody reports batches per second and not requests per second, and where the noise in a measurement comes from.Fixes # (issue)
Type of change
How Has This Been Tested?
npm run build,npm run testandnpm run lintin the package, all cleanReproduce with:
npm run build --workspace @sourceloop/benchmarking npm run test --workspace @sourceloop/benchmarking npm run lint --workspace @sourceloop/benchmarking CI=true npm run test:benchmark --workspace @sourceloop/benchmarkingNote that
engines.nodeis^22.12.0 || >=24for this package, not the usual22 || 24. tinybench 5 is ESM only, andrequire(esm)is stable from Node 22.12 onwards. The README explains this.Checklist: