Benchmarking
microbench
Benchmarks you can compare, check for noise and publish, in a zero-dependency Dart package.
Published Dec 4, 2026 · 1 day ago
dart pub add dev:microbenchRuns on
- Android
- iOS
- Windows
- Linux
- macOS
- Web
- Wasm
Quickstart
Install it, import it, and you are ready. This example comes straight from the README on the repository’s default branch, so it never drifts from the docs.
More recipes in the guideimport 'package:microbench/suite.dart';
void main() {
group('Repeat one char, 1000 times', () {
benchmark('+ operator', () {
var s = '';
for (var i = 0; i < 1000; i++) {
s += 'x';
}
return s;
});
benchmark('StringBuffer', () {
final sb = StringBuffer();
for (var i = 0; i < 1000; i++) {
sb.write('x');
}
return sb.toString();
});
benchmark('* operator', () => 'x' * 1000);
});
}What's new in next
Changelog →- Breaking Changes:
Measurement.runtimeMicrosis the 10th percentile of the samples, not the median. Interference only ever slows a batch, so the low end repeats across runs (0.06% spread against 0.14% for the median).bestMicros,worstMicros,meanMicros,cvand the samples are unchanged. - Breaking Changes:
BenchmarkOptions.warmupis the least warmup time; it now lasts until the per-call time stops improving, since a fixed warmup can end while the JIT is still speeding the code up, which made two runs of one benchmark differ by a percent or more. - Breaking Changes: batching follows the run's length: a run slower than
batchTargetis measured one per batch, and a batch too fast to time grows until it is measurable. - Breaking Changes:
durationis now the longest time spent measuring. The exercise phase stops as soon as the low end has settled forBenchmarkOptions.minSamplesbatches (new, default 40), so a run usually finishes well before it:--standardon a small benchmark dropped from about 2.1 s to 0.3-1.5 s with the same answer. RaiseminSamplesto always spend the fullduration. BenchmarkSettings.formatsnames aTableRenderer, so--format=NAMEand--out=FILE.NAMEreach a custom renderer inrunMain.compare,matrixandrunComparisonin a plainvoid main()pick up the runner's options (--quick,--filter,--format,--verify).benchmarkColumns(name, {column: run}, sizes: [...])declares one row measured in several columns, in a suite.test_integration/: a public-API smoke test, run on the VM and on node.
next0.4.00.3.10.3.00.2.00.1.0
Documentation
Guide
Install, quickstart, usage and recipes.
microbench guides
Guide from the repository docs.
Working with comparison tables
Guide from the repository docs.
Your first benchmark
Guide from the repository docs.
Migrating from benchmark_harness
Guide from the repository docs.
Reading the results
Guide from the repository docs.
Designing comparisons
Guide from the repository docs.
Reports and regression checks
Guide from the repository docs.
Getting trustworthy numbers
Guide from the repository docs.
Changelog
Every release and what changed.
API reference
Generated reference for every public symbol.