---
title: Tinybench reference
description: Reference documentation for the Allure Tinybench integration | runWithAllure | Recorded metrics | Limitations
---

# Allure Tinybench reference

## runWithAllure

- `runWithAllure(bench: Bench): Promise<Task[]>`

Runs the benchmark once with `bench.run()` and returns the same tasks as `bench.run()`. After the run, it records the results of all tasks as [performance metrics](/docs/performance-metrics/), in one batch.

```js
import { runWithAllure } from "allure-tinybench";
import { Bench } from "tinybench";

const bench = new Bench({ time: 100 });

bench.add("json.parse.simple", () => JSON.parse('{"status":"passed"}'));

const tasks = await runWithAllure(bench);
```

`runWithAllure()` must be called during a test run with an Allure integration for JavaScript. Without one, Allure prints a warning and records nothing.

## Recorded metrics

For each task, one measurement is recorded:

| Field   | Value                                                                  |
| ------- | ---------------------------------------------------------------------- |
| `key`   | The name of the task.                                                  |
| `value` | The mean duration of the task, in milliseconds.                        |
| `start` | The time when the benchmark run started. It's the same for all tasks.  |
| `stop`  | The time when the benchmark run finished. It's the same for all tasks. |

Only completed tasks are recorded, as well as aborted tasks for which Tinybench still provides statistics. Tasks with an empty name are skipped.

## Limitations

- The task names are used as metric keys, so keep them unique and stable across runs. When a task is renamed, Allure treats it as a new metric.
- Don't run the same `Bench` instance with `runWithAllure()` several times at once. Different `Bench` instances can run at the same time.
