@@ -157,6 +157,28 @@ bench.concurrency = 'task' // The concurrency mode to determine how tasks are ru
|
157 | 157 | await bench.run() |
158 | 158 | ``` |
159 | 159 | |
| 160 | +## Retaining Samples |
| 161 | + |
| 162 | +By default Tinybench does not keep the samples for `latency` and `throughput` to |
| 163 | +minimize memory usage. Enable sample retention if you need the raw samples for |
| 164 | +plotting, custom analysis, or exporting results. |
| 165 | + |
| 166 | +You can enable samples retention at the bench level by setting the |
| 167 | +`retainSamples` option to `true` when creating a `Bench` instance: |
| 168 | + |
| 169 | +```ts |
| 170 | +const bench = new Bench({ retainSamples: true }) |
| 171 | +``` |
| 172 | + |
| 173 | +You can also enable samples retention by setting the `retainSamples` option to |
| 174 | +`true` when adding a task: |
| 175 | + |
| 176 | +```ts |
| 177 | +bench.add('task with samples', () => { |
| 178 | +// Task logic here |
| 179 | +}, { retainSamples: true }) |
| 180 | +``` |
| 181 | + |
160 | 182 | ## Aborting Benchmarks |
161 | 183 | |
162 | 184 | Tinybench supports aborting benchmarks using `AbortSignal` at both the bench and task levels: |
|