Skip to content
masterclass Buddy

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.

Subscribe
  • test
  • bench.compare()
  • bench.from()
  • toBeFasterThan()
  • toBeSlowerThan()
  • benchmark.include
  • benchmark.enabled

Source: Benchmarking | Guide | Vitest. Checked 2026-11-03.