Describe the bug
When bench is invoked at the top of the module his results are displayed twice.
Wrapping the bench call in a describe doesn't duplicate the results.
sum-without-describe.bench.ts
import { bench } from "vitest";
bench("sum", () => {
1 + 1;
});
sum-with-describe.bench.ts
import { bench, describe } from "vitest";
describe("sum", () => {
bench("a", () => {
1 + 1;
});
});
Result
✓ tests/sum-with-describe.bench.ts > sum 5789ms
name hz min max mean p75 p99 p995 p999 rme samples
· a 48,128,806.17 0.0000 0.0327 0.0000 0.0000 0.0000 0.0000 0.0001 ±0.05% 24064404
✓ tests/sum-without-describe.bench.ts 5748ms
name hz min max mean p75 p99 p995 p999 rme samples
· sum 48,075,917.04 0.0000 0.0334 0.0000 0.0000 0.0000 0.0000 0.0001 ±0.05% 24037959
✓ tests/sum-without-describe.bench.ts 5748ms
name hz min max mean p75 p99 p995 p999 rme samples
· sum 48,075,917.04 0.0000 0.0334 0.0000 0.0000 0.0000 0.0000 0.0001 ±0.05% 24037959
Reproduction
Code: https://github.com/marcalexiei/vitest-bench-playground
GitHub actions: https://github.com/marcalexiei/vitest-bench-playground/actions/runs/22277251116/job/64441360076
System Info
System:
OS: macOS 26.3
CPU: (8) arm64 Apple M3
Memory: 139.19 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.12.0 - /.nvm/versions/node/v24.12.0/bin/node
npm: 11.6.2 - /.nvm/versions/node/v24.12.0/bin/npm
pnpm: 10.28.2 - /.nvm/versions/node/v24.12.0/bin/pnpm
Browsers:
Chrome: 144.0.7559.133
Safari: 26.3
npmPackages:
vitest: 4.0.18 => 4.0.18
Used Package Manager
pnpm
Validations
Describe the bug
When
benchis invoked at the top of the module his results are displayed twice.Wrapping the
benchcall in adescribedoesn't duplicate the results.sum-without-describe.bench.ts
sum-with-describe.bench.ts
Result
Reproduction
Code: https://github.com/marcalexiei/vitest-bench-playground
GitHub actions: https://github.com/marcalexiei/vitest-bench-playground/actions/runs/22277251116/job/64441360076
System Info
System: OS: macOS 26.3 CPU: (8) arm64 Apple M3 Memory: 139.19 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.12.0 - /.nvm/versions/node/v24.12.0/bin/node npm: 11.6.2 - /.nvm/versions/node/v24.12.0/bin/npm pnpm: 10.28.2 - /.nvm/versions/node/v24.12.0/bin/pnpm Browsers: Chrome: 144.0.7559.133 Safari: 26.3 npmPackages: vitest: 4.0.18 => 4.0.18Used Package Manager
pnpm
Validations