Skip to content
pubscout

benchmark_harness

2.4.0, released 12 months ago by tools.dart.dev

A Dart benchmark harness for measuring code performance

WASM-ready
$ flutter pub add benchmark_harness
Source repository

What it does

Provides BenchmarkBase and AsyncBenchmarkBase classes to run microbenchmarks and report average runtimes. It also offers a command-line tool to execute benchmarks across different Dart runtimes.

AI-written summary of version 2.4.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • building microbenchmarks for Dart code
  • measuring performance of small functions or algorithms
  • comparing JIT vs AOT or JS/wasm builds

Skip it when

  • production code that needs to run in the app
  • performance testing that requires external services or UI interactions

Strengths

  • Simple API, no code generation needed
  • Supports both sync and async benchmarks
  • Command-line tool for multi-runtime execution

Weaknesses

  • Only works for Dart, not for Flutter widgets
  • Benchmark results can be affected by system load
  • Requires Dart 3.10+ for latest version

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:benchmark_harness/benchmark_harness.dart';

class TemplateBenchmark extends BenchmarkBase {
  const TemplateBenchmark() : super('Template');
  static void main() => const TemplateBenchmark().report();
  @override void run() {}
}

void main() => TemplateBenchmark.main();

Alternatives

Packages that do the same job and could replace benchmark_harness.

Works with

Packages commonly used together with benchmark_harness: ones it builds on, ones built on it, and its own family.