From 62a7fe6791fcbe796fcbf58a17e0ee88663b9555 Mon Sep 17 00:00:00 2001 From: YKK <44870505+ysknsid25@users.noreply.github.com> Date: Wed, 30 Sep 2026 17:43:37 +0900 Subject: [PATCH] docs(bench): Fix import statements and update benchmark examples (#11364) --- docs/guide/benchmarking.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/guide/benchmarking.md b/docs/guide/benchmarking.md index a3ad4fb28..a34ed3a6a 100644 --- a/docs/guide/benchmarking.md +++ b/docs/guide/benchmarking.md @@ -11,10 +11,10 @@ Vitest lets you write benchmarks alongside your tests using the `bench` fixture Use the `bench` fixture to define a benchmark. Call `.run()` to execute it: ```ts -import { expect, test } from 'vitest' +import { test } from 'vitest' test('parsing performance', async ({ bench }) => { - const result = await bench('parse', () => { + await bench('parse', () => { JSON.parse('{"key":"value"}') }).run() }) @@ -79,12 +79,12 @@ To execute benchmarks with another benchmarking engine or execution strategy, se Use `bench.compare()` to compare multiple benchmarks against each other: ```ts -import { expect, test } from 'vitest' +import { test } from 'vitest' test('compare JSON libraries', async ({ bench }) => { const input = '{"key":"value","nested":{"a":1}}' - const result = await bench.compare( + await bench.compare( bench('JSON.parse', () => { JSON.parse(input) }), @@ -105,7 +105,7 @@ You can pass [options](https://tinylibs.github.io/tinybench/interfaces/BenchOpti ```ts test('compare with options', async ({ bench }) => { - const result = await bench.compare( + await bench.compare( bench('lib1', () => { lib1() }), bench('lib2', () => { lib2() }), { @@ -120,7 +120,7 @@ You can also pass per-benchmark [options](https://tinylibs.github.io/tinybench/i ```ts test('benchmarks with setup', async ({ bench }) => { - const result = await bench.compare( + await bench.compare( bench('with-cache', () => { readFromCache() }), -- 2.51.2