Bare-minimum, highly customizable benchmarking utility for Dart.
I am aware that different implementations of benchmarking utilities in dart already exists, such as benchmarking_harness
. However, I needed an utility which was customizable especially in the reporting of the metrics and run count.
- Measure execution time of Dart functions
- Extremely easy-to-use setup and reporting (no classes required)
- Built-in warmup and setup phases
- Multiple metric types (average, min, max), with the possibility of implementing your own (example coming soon).
Add the package to your pubspec.yaml
, for now this is not available on pub, but I intend of publishing it in the near future. For this reason, this package can only be depended on using git dependencies.
dependencies:
benchmark:
git:
url: https://github.com/FabrizioG202/dart_benchmark.git
path: benchmark
Then run:
dart pub get
void main()
{
// Set up logging
final logger = Logger('FibonacciBenchmark');
final subscription = logger.onRecord.listen((record) => print(record.message));
// Run the Benchmark
final times = benchmark(() => fibRecursive(32), 10);
// Log Results
logDurationMetrics(times, logger: logger, metrics: metrics);
// Close the subscription to the logger
unawaited(subscription.cancel());
}
This will output something like:
Benchmark Results:
average: 2.54 ms
min: 2.31 ms
max: 2.89 ms
- More default metrics.
- Performance Comparisons.
- Custom Precision in Duration Formatting.
- Async Support (Support for asynchronous functions)
- Better Metrics (Standard Deviation, etc.)
- Logging to File.
This project is licensed under the MIT License.