-
-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Description
I don't know what causes this, but all results seem completely off-bounds.
Reproduction
/* eslint-disable no-console */
import { Bench } from "tinybench";
const suite = new Bench({ iterations: 100_000 });
suite
.add("10", () => {
for (let i = 0; i < 10; i++);
})
.add("1 000", () => {
for (let i = 0; i < 1_000; i++);
})
.add("100 000", () => {
for (let i = 0; i < 100_000; i++);
});
suite.tasks.forEach((task) => {
task.addEventListener("complete", () => {
console.log(`${task.name}\t\t${task.result.mean * 1000}`);
});
});
await suite.warmup();
await suite.run();
console.table(suite.tasks.map(({ name, result }) => ({ "Task Name": name, "Average Time (ps)": result.mean * 1000, "Variance (ps)": result.variance * 1000 })));Output:
10 33.51586236828007
1 000 33.56626915780828
100 000 33.56723708981648
┌─────────┬───────────┬───────────────────┬─────────────────────┐
│ (index) │ Task Name │ Average Time (ps) │ Variance (ps) │
├─────────┼───────────┼───────────────────┼─────────────────────┤
│ 0 │ '10' │ 33.51586236828007 │ 0.13611378835207122 │
│ 1 │ '1 000' │ 33.56626915780828 │ 0.12475075068569264 │
│ 2 │ '100 000' │ 33.56723708981648 │ 0.13970421827784552 │
└─────────┴───────────┴───────────────────┴─────────────────────┘Two things here:
- They all seem to take as long, which is not possible.
- They all send their "complete" event at the same time.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels