-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
web_benchmarks_test.dart
51 lines (45 loc) · 1.45 KB
/
web_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
// Copyright 2013 The Flutter Authors. 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';
Future<void> main() async {
test('Can run a web benchmark', () async {
final BenchmarkResults taskResult = await serveWebBenchmark(
benchmarkAppDirectory: Directory('testing/test_app'),
entryPoint: 'lib/benchmarks/runner.dart',
useCanvasKit: false,
);
for (final String benchmarkName in <String>['scroll', 'page', 'tap']) {
for (final String metricName in <String>[
'preroll_frame',
'apply_frame',
'drawFrameDuration',
]) {
for (final String valueName in <String>[
'average',
'outlierAverage',
'outlierRatio',
'noise',
]) {
expect(
taskResult.scores[benchmarkName].where((BenchmarkScore score) =>
score.metric == '$metricName.$valueName'),
hasLength(1),
);
}
}
expect(
taskResult.scores[benchmarkName].where(
(BenchmarkScore score) => score.metric == 'totalUiFrame.average'),
hasLength(1),
);
}
expect(
const JsonEncoder.withIndent(' ').convert(taskResult.toJson()),
isA<String>(),
);
}, timeout: Timeout.none);
}