Gathering detailed insights and metrics for @codspeed/tinybench-plugin
Gathering detailed insights and metrics for @codspeed/tinybench-plugin
Gathering detailed insights and metrics for @codspeed/tinybench-plugin
Gathering detailed insights and metrics for @codspeed/tinybench-plugin
Node.js libraries to create CodSpeed benchmarks
npm install @codspeed/tinybench-plugin
Typescript
Module System
Node Version
NPM Version
69.8
Supply Chain
95.8
Quality
79.8
Maintenance
100
Vulnerability
100
License
TypeScript (87.04%)
C++ (7.57%)
JavaScript (3.96%)
Python (0.71%)
Shell (0.71%)
Total Downloads
74,694
Last Day
130
Last Week
1,578
Last Month
8,597
Last Year
36,889
Apache-2.0 License
17 Stars
155 Commits
3 Forks
1 Watchers
12 Branches
6 Contributors
Updated on May 21, 2025
Minified
Minified + Gzipped
Latest Version
4.0.1
Package Id
@codspeed/tinybench-plugin@4.0.1
Unpacked Size
47.21 kB
Size
10.25 kB
File Count
9
NPM Version
9.5.1
Node Version
18.16.0
Published on
Mar 24, 2025
Cumulative downloads
Total Downloads
Last Day
120.3%
130
Compared to previous day
Last Week
-53.2%
1,578
Compared to previous week
Last Month
208.4%
8,597
Compared to previous month
Last Year
3%
36,889
Compared to previous year
2
1
3
Check out the documentation for complete integration instructions.
First, install the plugin @codspeed/tinybench-plugin
and tinybench
(if not already installed):
1npm install --save-dev @codspeed/tinybench-plugin tinybench
or with yarn
:
1yarn add --dev @codspeed/tinybench-plugin tinybench
or with pnpm
:
1pnpm add --save-dev @codspeed/tinybench-plugin tinybench
Let's create a fibonacci function and benchmark it with tinybench and the CodSpeed plugin:
1import { Bench } from "tinybench"; 2import { withCodSpeed } from "@codspeed/tinybench-plugin"; 3 4function fibonacci(n) { 5 if (n < 2) { 6 return n; 7 } 8 return fibonacci(n - 1) + fibonacci(n - 2); 9} 10 11const bench = withCodSpeed(new Bench()); 12 13bench 14 .add("fibonacci10", () => { 15 fibonacci(10); 16 }) 17 .add("fibonacci15", () => { 18 fibonacci(15); 19 }); 20 21await bench.run(); 22console.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:
1$ node benches/bench.mjs 2[CodSpeed] 2 benches detected but no instrumentation found 3[CodSpeed] falling back to tinybench 4 5┌─────────┬───────────────┬─────────────┬───────────────────┬──────────┬─────────┐ 6│ (index) │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │ 7├─────────┼───────────────┼─────────────┼───────────────────┼──────────┼─────────┤ 8│ 0 │ 'fibonacci10' │ '1,810,236' │ 552.4139857896414 │ '±0.18%' │ 905119 │ 9│ 1 │ 'fibonacci15' │ '177,516' │ 5633.276191749634 │ '±0.14%' │ 88759 │ 10└─────────┴───────────────┴─────────────┴───────────────────┴──────────┴─────────┘
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.
No vulnerabilities found.
No security vulnerabilities found.