Skip to content

Bare-minimum, highly customizable benchmarking utility for Dart.

License

Notifications You must be signed in to change notification settings

FabrizioG202/dart_benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Benchmark Utility for Dart.

Bare-minimum, highly customizable benchmarking utility for Dart.

Why?

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.

Features

  • 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).

Installation

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

Simple Example

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

Roadmap

  • More default metrics.
  • Performance Comparisons.
  • Custom Precision in Duration Formatting.
  • Async Support (Support for asynchronous functions)
  • Better Metrics (Standard Deviation, etc.)
  • Logging to File.

License

This project is licensed under the MIT License.

About

Bare-minimum, highly customizable benchmarking utility for Dart.

Topics

Resources

License

Stars

Watchers

Forks

Languages