Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit 197702c

Browse files
authored
Version 2.3.0 (#102)
* Version 2.3.0 - Update SDK requirement to Dart 3.2. - Add a ScoreEmitterV2 interface, that the ScoreEmitter interface will be changed to in the next major release, a breaking change. - Add `PerfBenchmarkBase` class which runs the 'perf stat' command from linux-tools on a benchmark and reports metrics from the hardware performance counters and the benchmark iteration count. The breaking change to ScoreEmitter in 2.2.3 is reverted, and version 2.2.3 is retracted from pub. * Update version number * Improve documentation
1 parent aa139fd commit 197702c

7 files changed

+37
-12
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
## 2.2.3
1+
## 2.3.0
22

33
- Require Dart 3.2.
4+
- Add ScoreEmitterV2 interface, documented with the intention to change
5+
ScoreEmitter interface to match it in the next major release,
6+
a breaking change.
47
- Add `PerfBenchmarkBase` class which runs the 'perf stat' command from
58
linux-tools on a benchmark and reports metrics from the hardware
69
performance counters and the iteration count, as well as the run time

lib/src/async_benchmark_base.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ class AsyncBenchmarkBase {
6464

6565
/// Run the benchmark and report results on the [emitter].
6666
Future<void> report() async {
67-
emitter.emit(name, await measure(), unit: 'us.');
67+
emitter.emit(name, await measure());
6868
}
6969
}

lib/src/benchmark_base.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class BenchmarkBase {
5858
}
5959

6060
void report() {
61-
emitter.emit(name, measure(), unit: 'us.');
61+
emitter.emit(name, measure());
6262
}
6363
}
6464

lib/src/perf_benchmark_base.dart

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ class PerfBenchmarkBase extends BenchmarkBase {
1818
late final Process perfProcess;
1919
late final List<String> perfProcessArgs;
2020

21-
PerfBenchmarkBase(super.name, {super.emitter = const PrintEmitter()});
21+
PerfBenchmarkBase(super.name,
22+
{ScoreEmitterV2 super.emitter = const PrintEmitterV2()});
23+
24+
ScoreEmitterV2 get _emitterV2 => emitter as ScoreEmitterV2;
2225

2326
Future<void> _createFifos() async {
2427
perfControlFifo = '${fifoDir.path}/perf_control_fifo';
@@ -81,11 +84,11 @@ class PerfBenchmarkBase extends BenchmarkBase {
8184
String event && ('cycles' || 'page-faults'),
8285
...
8386
]) {
84-
emitter.emit(name, double.parse(counter) / totalIterations,
87+
_emitterV2.emit(name, double.parse(counter) / totalIterations,
8588
metric: metrics[event]!);
8689
}
8790
}
88-
emitter.emit('$name.totalIterations', totalIterations.toDouble(),
91+
_emitterV2.emit('$name.totalIterations', totalIterations.toDouble(),
8992
metric: 'Count');
9093
}
9194

@@ -118,7 +121,7 @@ class PerfBenchmarkBase extends BenchmarkBase {
118121
}
119122

120123
Future<void> reportPerf() async {
121-
emitter.emit(name, await measurePerf(), unit: 'us.');
124+
_emitterV2.emit(name, await measurePerf(), unit: 'us.');
122125
}
123126

124127
void _waitForAck() {

lib/src/score_emitter.dart

+22-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,33 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
abstract class ScoreEmitter {
6-
void emit(String testName, double value,
7-
{String metric = 'RunTime', String unit});
6+
void emit(String testName, double value);
87
}
98

109
class PrintEmitter implements ScoreEmitter {
1110
const PrintEmitter();
1211

12+
@override
13+
void emit(String testName, double value) {
14+
print('$testName(RunTime): $value us.');
15+
}
16+
}
17+
18+
/// New interface for [ScoreEmitter]. [ScoreEmitter] will be changed to
19+
/// this interface in the next major version release, and this class will
20+
/// be deprecated and removed. That release will be a breaking change.
21+
abstract class ScoreEmitterV2 implements ScoreEmitter {
22+
@override
23+
void emit(String testName, double value,
24+
{String metric = 'RunTime', String unit});
25+
}
26+
27+
/// New implementation of [PrintEmitter] implementing the [ScoreEmitterV2]
28+
/// interface. [PrintEmitter] will be changed to this implementation in the
29+
/// next major version release.
30+
class PrintEmitterV2 implements ScoreEmitterV2 {
31+
const PrintEmitterV2();
32+
1333
@override
1434
void emit(String testName, double value,
1535
{String metric = 'RunTime', String unit = ''}) {

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: benchmark_harness
2-
version: 2.2.3
2+
version: 2.3.0
33
description: The official Dart project benchmark harness.
44
repository: https://github.com/dart-lang/benchmark_harness
55

test/result_emitter_test.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class MockResultEmitter extends ScoreEmitter {
1313
int emitCount = 0;
1414

1515
@override
16-
void emit(String name, double value,
17-
{String metric = 'RunTime', String unit = ''}) {
16+
void emit(String name, double value) {
1817
emitCount++;
1918
}
2019
}

0 commit comments

Comments
 (0)