Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/tinybench table #19

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions examples/with-javascript-cjs/tinybench.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,5 @@ bench
});

bench.run().then(() => {
console.table(
bench.tasks.map(({ name, result }) => ({
"Task Name": name,
"Average Time (ps)": result?.mean ? result.mean * 1000 : "N/A",
"Variance (ps)": result?.variance ? result.variance * 1000 : "N/A",
}))
);
console.table(bench.table());
});
8 changes: 1 addition & 7 deletions examples/with-javascript-esm/tinybench.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,5 @@ bench
});

bench.run().then(() => {
console.table(
bench.tasks.map(({ name, result }) => ({
"Task Name": name,
"Average Time (ps)": result?.mean ? result.mean * 1000 : "N/A",
"Variance (ps)": result?.variance ? result.variance * 1000 : "N/A",
}))
);
console.table(bench.table());
});
8 changes: 1 addition & 7 deletions examples/with-typescript-cjs/bench/tinybench/index.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,5 @@ export const bench = withCodSpeed(new Bench());
registerFoobarbazBenchmarks(bench);

await bench.run();
console.table(
bench.tasks.map(({ name, result }) => ({
"Task Name": name,
"Average Time (ps)": result?.mean ? result.mean * 1000 : "N/A",
"Variance (ps)": result?.variance ? result.variance * 1000 : "N/A",
}))
);
console.table(bench.table());
})();
1 change: 1 addition & 0 deletions examples/with-typescript-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@codspeed/tinybench-plugin": "workspace:*",
"@types/benchmark": "^2.1.2",
"benchmark": "^2.1.4",
"esbuild-register": "^3.4.2",
"tinybench": "^2.5.0",
"typescript": "^5.1.3"
}
Expand Down
8 changes: 1 addition & 7 deletions examples/with-typescript-esm/bench/tinybench/index.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,5 @@ export const bench = withCodSpeed(new Bench());
registerFoobarbazBenchmarks(bench);

await bench.run();
console.table(
bench.tasks.map(({ name, result }) => ({
"Task Name": name,
"Average Time (ps)": result?.mean ? result.mean * 1000 : "N/A",
"Variance (ps)": result?.variance ? result.variance * 1000 : "N/A",
}))
);
console.table(bench.table());
})();
1 change: 1 addition & 0 deletions examples/with-typescript-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@codspeed/tinybench-plugin": "workspace:*",
"@types/benchmark": "^2.1.2",
"benchmark": "^2.1.4",
"esbuild-register": "^3.4.2",
"tinybench": "^2.5.0",
"typescript": "^5.1.3"
}
Expand Down
8 changes: 1 addition & 7 deletions examples/with-typescript-simple-cjs/tinybench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,5 @@ bench
});

bench.run().then(() => {
console.table(
bench.tasks.map(({ name, result }) => ({
"Task Name": name,
"Average Time (ps)": result?.mean ? result.mean * 1000 : "N/A",
"Variance (ps)": result?.variance ? result.variance * 1000 : "N/A",
}))
);
console.table(bench.table());
});
8 changes: 1 addition & 7 deletions examples/with-typescript-simple-esm/tinybench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,5 @@ bench
});

bench.run().then(() => {
console.table(
bench.tasks.map(({ name, result }) => ({
"Task Name": name,
"Average Time (ps)": result?.mean ? result.mean * 1000 : "N/A",
"Variance (ps)": result?.variance ? result.variance * 1000 : "N/A",
}))
);
console.table(bench.table());
});
19 changes: 7 additions & 12 deletions packages/tinybench-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ bench
});

await bench.run();
console.table(
bench.tasks.map(({ name, result }) => ({
"Task Name": name,
"Average Time (ps)": result?.mean * 1000,
}))
);
console.table(bench.table());
```

Here, a few things are happening:
Expand All @@ -81,12 +76,12 @@ $ node benches/bench.mjs
[CodSpeed] 2 benches detected but no instrumentation found
[CodSpeed] falling back to tinybench

┌─────────┬───────────────┬────────────────────┐
│ (index) │ Task Name │ Average Time (ps)
├─────────┼───────────────┼────────────────────┤
│ 0 │ 'fibonacci10' │ 0.5660083779532603
│ 1 │ 'fibonacci15' │ 5.2475729101797635
└─────────┴───────────────┴────────────────────┘
┌─────────┬───────────────┬─────────────┬───────────────────┬──────────┬─────────┐
│ (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.
Expand Down
8 changes: 1 addition & 7 deletions packages/tinybench-plugin/benches/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,5 @@ bench
});

bench.run().then(() => {
console.table(
bench.tasks.map(({ name, result }) => ({
"Task Name": name,
"Average Time (ps)": result?.mean ? result.mean * 1000 : "N/A",
"Variance (ps)": result?.variance ? result.variance * 1000 : "N/A",
}))
);
console.table(bench.table());
});
2 changes: 1 addition & 1 deletion packages/tinybench-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/find-up": "^4.0.0",
"@types/stack-trace": "^0.0.30",
"jest-mock-extended": "^3.0.4",
"tinybench": "^2.4.0"
"tinybench": "^2.5.0"
},
"dependencies": {
"@codspeed/core": "workspace:^2.1.0",
Expand Down
Loading