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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright (c) 2016 The Chromium 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:async';
import 'dart:io';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import '../framework/benchmarks.dart';
import '../framework/framework.dart';
import '../framework/utils.dart';
TaskFunction createAnalyzerCliTest({
@required String sdk,
@required String commit,
@required DateTime timestamp,
}) {
return new AnalyzerCliTask(sdk, commit, timestamp);
}
TaskFunction createAnalyzerServerTest({
@required String sdk,
@required String commit,
@required DateTime timestamp,
}) {
return new AnalyzerServerTask(sdk, commit, timestamp);
}
abstract class AnalyzerTask {
Benchmark benchmark;
Future<TaskResult> call() async {
section(benchmark.name);
await runBenchmark(benchmark, iterations: 3, warmUpBenchmark: true);
return benchmark.bestResult;
}
}
class AnalyzerCliTask extends AnalyzerTask {
AnalyzerCliTask(String sdk, String commit, DateTime timestamp) {
benchmark = new FlutterAnalyzeBenchmark(sdk, commit, timestamp);
}
}
class AnalyzerServerTask extends AnalyzerTask {
AnalyzerServerTask(String sdk, String commit, DateTime timestamp) {
benchmark = new FlutterAnalyzeAppBenchmark(sdk, commit, timestamp);
}
}
class FlutterAnalyzeBenchmark extends Benchmark {
FlutterAnalyzeBenchmark(this.sdk, this.commit, this.timestamp)
: super('flutter analyze --flutter-repo');
final String sdk;
final String commit;
final DateTime timestamp;
File get benchmarkFile =>
file(path.join(flutterDirectory.path, 'analysis_benchmark.json'));
@override
TaskResult get lastResult => new TaskResult.successFromFile(benchmarkFile);
@override
Future<num> run() async {
rm(benchmarkFile);
await inDirectory(flutterDirectory, () async {
await flutter('analyze', options: <String>[
'--flutter-repo',
'--benchmark',
]);
});
return addBuildInfo(benchmarkFile,
timestamp: timestamp, expected: 25.0, sdk: sdk, commit: commit);
}
}
class FlutterAnalyzeAppBenchmark extends Benchmark {
FlutterAnalyzeAppBenchmark(this.sdk, this.commit, this.timestamp)
: super('analysis server mega_gallery');
final String sdk;
final String commit;
final DateTime timestamp;
@override
TaskResult get lastResult => new TaskResult.successFromFile(benchmarkFile);
Directory get megaDir => dir(
path.join(flutterDirectory.path, 'dev/benchmarks/mega_gallery'));
File get benchmarkFile =>
file(path.join(megaDir.path, 'analysis_benchmark.json'));
@override
Future<Null> init() {
return inDirectory(flutterDirectory, () async {
await dart(<String>['dev/tools/mega_gallery.dart']);
});
}
@override
Future<num> run() async {
rm(benchmarkFile);
await inDirectory(megaDir, () async {
await flutter('analyze', options: <String>[
'--watch',
'--benchmark',
]);
});
return addBuildInfo(benchmarkFile,
timestamp: timestamp, expected: 10.0, sdk: sdk, commit: commit);
}
}