Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Dart Benchmark Harness #
==========================
## Introduction ##
The Dart project benchmark harness is the recommended starting point when building a benchmark for Dart.
## Features ##
* ```BenchmarkBase``` class that all new benchmarks should ```extend```
* Two sample benchmarks (DeltaBlue & Richards)
* Template benchmark that you can copy and paste when building new benchmarks
## Getting Started ##
1\. Add the following to your project's **pubspec.yaml**
```
dependencies:
benchmark_harness:
git: https://github.com/dart-lang/benchmark_harness.git
```
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```
## Example ##
```
// 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();
}
```