Vitest · Function
bench
The bench fixture defines and runs performance benchmarks inside Vitest tests. Use .run() for one benchmark or bench.compare() to compare several benchmarks.
Last updated
- Since
- 5.0.0
Syntax
test(name, async ({ bench }) => { await bench(benchmarkName, options?, fn).run() })In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
testbench.compare()bench.from()toBeFasterThan()toBeSlowerThan()benchmark.includebenchmark.enabled