benchmark
0.3.0, released 6 years ago by wolfenrain.dev
A full featured library for writing and running Dart benchmarks.
WASM-ready
$ flutter pub add benchmarkWhat it does
Provides a standard way of writing and running benchmarks in Dart with support for groups, setup, and teardown functions. Includes a command-line executable to automatically run benchmarks.
AI-written summary of version 0.3.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to measure the performance of specific Dart code snippets or functions.
- You need grouping and setup/teardown capabilities for organizing benchmarks.
Skip it when
- You are looking for UI widget testing or golden tests.
Strengths
- Clean syntax inspired by the test package and benchmark_harness.
- Supports groups, setUp, tearDown, setUpEach, and tearDownEach.
- Includes a built-in command line runner for execution.
Weaknesses
- Limited documentation beyond basic examples.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Add benchmark to dependencies and run using pub run benchmark.
import 'package:benchmark/benchmark.dart';
void main() {
benchmark('List.generate(100k)', () {
List.generate(100000, (i) => i);
});
}Alternatives
Packages that do the same job and could replace benchmark.
Works with
Packages commonly used together with benchmark: ones it builds on, ones built on it, and its own family.