forked from flutter/gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmarks_test.dart
75 lines (62 loc) · 1.96 KB
/
benchmarks_test.dart
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
69
70
71
72
73
74
75
// Copyright 2020 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:convert' show JsonEncoder;
import 'dart:io';
import 'package:test/test.dart';
import 'package:web_benchmarks/server.dart';
import 'benchmarks/common.dart';
import 'benchmarks/project_root_directory.dart';
final metricList = <String>[
'preroll_frame',
'apply_frame',
'drawFrameDuration',
];
final valueList = <String>[
'average',
'outlierAverage',
'outlierRatio',
'noise',
];
/// Tests that the Gallery web benchmarks are run and reported correctly.
Future<void> main() async {
test('Can run a web benchmark', () async {
stdout.writeln('Starting web benchmark tests ...');
final taskResult = await serveWebBenchmark(
benchmarkAppDirectory: projectRootDirectory(),
entryPoint: 'test_benchmarks/benchmarks/client.dart',
useCanvasKit: false,
);
stdout.writeln('Web benchmark tests finished.');
expect(taskResult.scores.keys, hasLength(benchmarkList.length));
for (final benchmarkName in benchmarkList) {
expect(
taskResult.scores[benchmarkName],
hasLength(metricList.length * valueList.length + 1),
);
for (final metricName in metricList) {
for (final valueName in valueList) {
expect(
taskResult.scores[benchmarkName]?.where(
(score) => score.metric == '$metricName.$valueName',
),
hasLength(1),
);
}
}
expect(
taskResult.scores[benchmarkName]?.where(
(score) => score.metric == 'totalUiFrame.average',
),
hasLength(1),
);
}
expect(
const JsonEncoder.withIndent(' ').convert(taskResult.toJson()),
isA<String>(),
);
},
timeout: Timeout.none,
skip:
true); // TODO(guidezpl): re-enable these benchmarks https://github.com/flutter/gallery/issues/903
}