Skip to content

Commit 572d9b6

Browse files
UzlopakCopilot
andauthored
perf!: allow reducing data retention, by adding retainSamples option on bench and task level, default is false (#421)
* perf: reduce data retention * Update src/task.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix lint * add retainSamples option * fix * fix * fix * fix linting etc. * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0667640 commit 572d9b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+528
-301
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,28 @@ bench.concurrency = 'task' // The concurrency mode to determine how tasks are ru
157157
await bench.run()
158158
```
159159

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+
160182
## Aborting Benchmarks
161183

162184
Tinybench supports aborting benchmarks using `AbortSignal` at both the bench and task levels:

docs/assets/hierarchy.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/navigation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)