@@ -19,27 +19,45 @@ Future<void> main() async {
1919 }, timeout: Timeout .none);
2020
2121 test ('Can run a web benchmark with an alternate initial page' , () async {
22- await _runBenchmarks (
22+ final BenchmarkResults results = await _runBenchmarks (
2323 benchmarkNames: < String > ['simple' ],
2424 entryPoint: 'lib/benchmarks/runner_simple.dart' ,
2525 initialPage: 'index.html#about' ,
2626 );
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 );
2736 }, timeout: Timeout .none);
2837
2938 test (
3039 'Can run a web benchmark with wasm' ,
3140 () async {
32- await _runBenchmarks (
41+ final BenchmarkResults results = await _runBenchmarks (
3342 benchmarkNames: < String > ['simple' ],
3443 entryPoint: 'lib/benchmarks/runner_simple.dart' ,
3544 compilationOptions: const CompilationOptions .wasm (),
3645 );
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 );
3755 },
3856 timeout: Timeout .none,
3957 );
4058}
4159
42- Future <void > _runBenchmarks ({
60+ Future <BenchmarkResults > _runBenchmarks ({
4361 required List <String > benchmarkNames,
4462 required String entryPoint,
4563 String initialPage = defaultInitialPage,
@@ -53,12 +71,17 @@ Future<void> _runBenchmarks({
5371 compilationOptions: compilationOptions,
5472 );
5573
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+
5683 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) {
6285 for (final String valueName in < String > [
6386 'average' ,
6487 'outlierAverage' ,
@@ -83,4 +106,5 @@ Future<void> _runBenchmarks({
83106 const JsonEncoder .withIndent (' ' ).convert (taskResult.toJson ()),
84107 isA <String >(),
85108 );
109+ return taskResult;
86110}
0 commit comments