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
64.4
Supply Chain
95.1
Quality
79.2
Maintenance
100
Vulnerability
100
License
TypeScript (87.04%)
C++ (7.57%)
JavaScript (3.96%)
Python (0.71%)
Shell (0.71%)
Love this project? Help keep it running β sponsor us today! π
Total Downloads
58,463
Last Day
86
Last Week
627
Last Month
2,414
Last Year
50,673
Apache-2.0 License
16 Stars
153 Commits
2 Forks
1 Watchers
12 Branches
4 Contributors
Updated on Jan 28, 2025
Minified
Minified + Gzipped
Latest Version
4.0.0
Package Id
@codspeed/tinybench-plugin@4.0.0
Unpacked Size
47.21 kB
Size
10.25 kB
File Count
9
NPM Version
9.5.1
Node Version
18.16.0
Published on
Dec 11, 2024
Cumulative downloads
Total Downloads
Last Day
87%
86
Compared to previous day
Last Week
35.1%
627
Compared to previous week
Last Month
14.2%
2,414
Compared to previous month
Last Year
587.6%
50,673
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.