Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@codspeed/tinybench-plugin
Advanced tools
Check out the documentation for complete integration instructions.
First, install the plugin @codspeed/tinybench-plugin
and tinybench
(if not already installed):
npm install --save-dev @codspeed/tinybench-plugin tinybench
or with yarn
:
yarn add --dev @codspeed/tinybench-plugin tinybench
or with pnpm
:
pnpm add --save-dev @codspeed/tinybench-plugin tinybench
Let's create a fibonacci function and benchmark it with tinybench and the CodSpeed plugin:
import { Bench } from "tinybench";
import { withCodSpeed } from "@codspeed/tinybench-plugin";
function fibonacci(n) {
if (n < 2) {
return n;
}
return fibonacci(n - 1) + fibonacci(n - 2);
}
const bench = withCodSpeed(new Bench());
bench
.add("fibonacci10", () => {
fibonacci(10);
})
.add("fibonacci15", () => {
fibonacci(15);
});
await bench.run();
console.table(bench.table());
Here, a few things are happening:
We create a simple recursive fibonacci function.
We create a new Bench
instance with CodSpeed support by using the withCodSpeed
helper. This step is critical to enable CodSpeed on your benchmarks.
We add two benchmarks to the suite and launch it, benching our fibonacci
function for 10 and 15.
Now, we can run our benchmarks locally to make sure everything is working as expected:
$ node benches/bench.mjs
[CodSpeed] 2 benches detected but no instrumentation found
[CodSpeed] falling back to tinybench
┌─────────┬───────────────┬─────────────┬───────────────────┬──────────┬─────────┐
│ (index) │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │
├─────────┼───────────────┼─────────────┼───────────────────┼──────────┼─────────┤
│ 0 │ 'fibonacci10' │ '1,810,236' │ 552.4139857896414 │ '±0.18%' │ 905119 │
│ 1 │ 'fibonacci15' │ '177,516' │ 5633.276191749634 │ '±0.14%' │ 88759 │
└─────────┴───────────────┴─────────────┴───────────────────┴──────────┴─────────┘
And... Congrats🎉, CodSpeed is installed in your benchmarking suite! Locally, CodSpeed will fallback to tinybench since the instrumentation is only available in the CI environment for now.
You can now run those benchmarks in your CI to continuously get consistent performance measurements.
FAQs
tinybench compatibility layer for CodSpeed
The npm package @codspeed/tinybench-plugin receives a total of 211 weekly downloads. As such, @codspeed/tinybench-plugin popularity was classified as not popular.
We found that @codspeed/tinybench-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.