@@ -19,27 +19,45 @@ Future<void> main() async {
19
19
}, timeout: Timeout .none);
20
20
21
21
test ('Can run a web benchmark with an alternate initial page' , () async {
22
- await _runBenchmarks (
22
+ final BenchmarkResults results = await _runBenchmarks (
23
23
benchmarkNames: < String > ['simple' ],
24
24
entryPoint: 'lib/benchmarks/runner_simple.dart' ,
25
25
initialPage: 'index.html#about' ,
26
26
);
27
+
28
+ // The simple runner just puts an `isWasm` metric in there so we can make
29
+ // sure that we're running in the right environment.
30
+ final List <BenchmarkScore >? scores = results.scores['simple' ];
31
+ expect (scores, isNotNull);
32
+
33
+ final BenchmarkScore isWasmScore =
34
+ scores! .firstWhere ((BenchmarkScore score) => score.metric == 'isWasm' );
35
+ expect (isWasmScore.value, 0 );
27
36
}, timeout: Timeout .none);
28
37
29
38
test (
30
39
'Can run a web benchmark with wasm' ,
31
40
() async {
32
- await _runBenchmarks (
41
+ final BenchmarkResults results = await _runBenchmarks (
33
42
benchmarkNames: < String > ['simple' ],
34
43
entryPoint: 'lib/benchmarks/runner_simple.dart' ,
35
44
compilationOptions: const CompilationOptions .wasm (),
36
45
);
46
+
47
+ // The simple runner just puts an `isWasm` metric in there so we can make
48
+ // sure that we're running in the right environment.
49
+ final List <BenchmarkScore >? scores = results.scores['simple' ];
50
+ expect (scores, isNotNull);
51
+
52
+ final BenchmarkScore isWasmScore = scores!
53
+ .firstWhere ((BenchmarkScore score) => score.metric == 'isWasm' );
54
+ expect (isWasmScore.value, 1 );
37
55
},
38
56
timeout: Timeout .none,
39
57
);
40
58
}
41
59
42
- Future <void > _runBenchmarks ({
60
+ Future <BenchmarkResults > _runBenchmarks ({
43
61
required List <String > benchmarkNames,
44
62
required String entryPoint,
45
63
String initialPage = defaultInitialPage,
@@ -53,12 +71,17 @@ Future<void> _runBenchmarks({
53
71
compilationOptions: compilationOptions,
54
72
);
55
73
74
+ // The skwasm renderer doesn't have preroll or apply frame steps in its rendering.
75
+ final List <String > expectedMetrics = compilationOptions.useWasm
76
+ ? < String > ['drawFrameDuration' ]
77
+ : < String > [
78
+ 'preroll_frame' ,
79
+ 'apply_frame' ,
80
+ 'drawFrameDuration' ,
81
+ ];
82
+
56
83
for (final String benchmarkName in benchmarkNames) {
57
- for (final String metricName in < String > [
58
- 'preroll_frame' ,
59
- 'apply_frame' ,
60
- 'drawFrameDuration' ,
61
- ]) {
84
+ for (final String metricName in expectedMetrics) {
62
85
for (final String valueName in < String > [
63
86
'average' ,
64
87
'outlierAverage' ,
@@ -83,4 +106,5 @@ Future<void> _runBenchmarks({
83
106
const JsonEncoder .withIndent (' ' ).convert (taskResult.toJson ()),
84
107
isA <String >(),
85
108
);
109
+ return taskResult;
86
110
}
0 commit comments