commit | 9390267dcd23289d92adea6fd146e5660b6a67da | [log] [tgz] |
---|---|---|
author | devoncarew@google.com <devoncarew@google.com> | Sun Mar 02 04:56:29 2014 -0800 |
committer | devoncarew@google.com <devoncarew@google.com> | Sun Mar 02 04:56:29 2014 -0800 |
tree | ffce0a92f5591ac6e5b2ff18d8fbc4f5abb32bc8 | |
parent | a0ae17c9d941f957e702339ebfd773a2a92806e7 [diff] |
change from the elapsedMilliseconds to elapsedMicroseconds
The Dart project benchmark harness is the recommended starting point when building a benchmark for Dart.
You can read more about Benchmarking the Dart VM.
By default, the reported runtime is not for a single call to run()
, but for the average time it takes to call run()
10 times. The benchmark harness executes a 10-call timing loop repeatedly until 2 seconds have elapsed; the reported result is the average of the runtimes for each loop.
If you are running the same benchmark, on the same machine, running the same OS, the reported run times can be carefully compared across runs. Carefully because there are a variety of factors which could cause error in the run time, for example, the load from other applications running on your machine could alter the result.
Comparing the run time of different benchmarks is not recommended. In other words, don't compare apples with oranges.
BenchmarkBase
class that all new benchmarks should extend
1. Add the following to your project's pubspec.yaml
dependencies: benchmark_harness: any
2. Install pub packages
pub install
3. Add the following import:
import 'package:benchmark_harness/benchmark_harness.dart';
4. Create a benchmark class which inherits from BenchmarkBase
// Import BenchmarkBase class. import 'package:benchmark_harness/benchmark_harness.dart'; // Create a new benchmark by extending BenchmarkBase class TemplateBenchmark extends BenchmarkBase { const TemplateBenchmark() : super("Template"); static void main() { new TemplateBenchmark().report(); } // The benchmark code. void run() { } // Not measured setup code executed prior to the benchmark runs. void setup() { } // Not measures teardown code executed after the benchark runs. void teardown() { } } main() { // Run TemplateBenchmark TemplateBenchmark.main(); }