Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: pkg/front_end/tool/fasta/abcompile.dart

Issue 2733033002: Revert "A/B fasta performance measurement harness" (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/front_end/tool/fasta/compile.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import 'dart:async';
2 import 'dart:convert';
3 import 'dart:math';
4 import 'dart:io';
5
6 import 'standard_deviation.dart';
7
8 const String bRootPath = const String.fromEnvironment("bRoot");
9 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1);
10
11 /// Compare the performance of two different fast implementations
12 /// by alternately launching the compile application in this directory
13 /// and the compile application location in the repo specified by "bRoot"
14 /// via -DbRoot=/absolute/path/to/other/sdk/repo
15 main(List<String> args) async {
16 print(args);
17 if (bRootPath == null) {
18 print('Expected -DbRoot=/absolute/path/to/other/sdk/repo');
19 exit(1);
20 }
21
22 // The root of this Dart SDK repo "A"
23 Uri aRoot = Platform.script.resolve('../../../..');
24
25 // The root of the other Dart SDK repo "B"
26 Uri bRoot = new Uri.directory(bRootPath);
27
28 // Sanity check
29 String relPath = 'pkg/front_end/tool/fasta/compile.dart';
30 Uri aCompile = aRoot.resolve(relPath);
31 if (!new File(aCompile.toFilePath()).existsSync()) {
32 print('Failed to find $aCompile');
33 exit(1);
34 }
35 Uri bCompile = bRoot.resolve(relPath);
36 if (!new File(bCompile.toFilePath()).existsSync()) {
37 print('Failed to find $bCompile');
38 exit(1);
39 }
40
41 print('Comparing:');
42 print('A: $aCompile');
43 print('B: $bCompile');
44 print('');
45
46 List<double> aCold = <double>[];
47 List<double> aWarm = <double>[];
48 List<double> bCold = <double>[];
49 List<double> bWarm = <double>[];
50 for (int count = 0; count < 15; ++count) {
51 await run(aRoot, aCompile, args, aCold, aWarm);
52 await run(bRoot, bCompile, args, bCold, bWarm);
53 }
54
55 print('');
56 print('Raw data:');
57 print('A cold, A warm, B cold, B warm');
58 for (int index = 0; index < aCold.length; ++index) {
59 print('${aCold[index]}, ${aWarm[index]}, ${bCold[index]}, ${bWarm[index]}');
60 }
61
62 double aColdMean = average(aCold);
63 double aWarmMean = average(aWarm);
64 double bColdMean = average(bCold);
65 double bWarmMean = average(bWarm);
66
67 print('');
68 print('Average:');
69 print('$aColdMean, $aWarmMean, $bColdMean, $bWarmMean');
70
71 double aColdStdDev = standardDeviation(aColdMean, aCold);
72 double aWarmStdDev = standardDeviation(aWarmMean, aWarm);
73 double bColdStdDev = standardDeviation(bColdMean, bCold);
74 double bWarmStdDev = standardDeviation(bWarmMean, bWarm);
75
76 double aColdStdDevMean = standardDeviationOfTheMean(aCold, aColdStdDev);
77 double aWarmStdDevMean = standardDeviationOfTheMean(aWarm, aWarmStdDev);
78 double bColdStdDevMean = standardDeviationOfTheMean(bCold, bColdStdDev);
79 double bWarmStdDevMean = standardDeviationOfTheMean(bWarm, bWarmStdDev);
80
81 print('');
82 print('Uncertainty:');
83 print(
84 '$aColdStdDevMean, $aWarmStdDevMean, $bColdStdDevMean, $bWarmStdDevMean');
85
86 double coldDelta = aColdMean - bColdMean;
87 double coldStdDevMean =
88 sqrt(pow(aColdStdDevMean, 2) + pow(bColdStdDevMean, 2));
89 double warmDelta = aWarmMean - bWarmMean;
90 double warmStdDevMean =
91 sqrt(pow(aWarmStdDevMean, 2) + pow(bWarmStdDevMean, 2));
92
93 print('');
94 print('Summary:');
95 print(' A cold start - B cold start : $coldDelta');
96 print(' Uncertainty : $coldStdDevMean');
97 print('');
98 print(' A warm runs - B warm runs : $warmDelta');
99 print(' Uncertainty : $warmStdDevMean');
100 }
101
102 const String _wroteProgram = 'Wrote program to';
103 const String _coldStart = 'Cold start (first run):';
104 const String _warmRun = 'Warm run average (runs #4';
105
106 /// Launch the specified dart program, forwarding all arguments and environment
107 /// that was passed to this program
108 Future<Null> run(Uri workingDir, Uri dartApp, List<String> args,
109 List<double> cold, List<double> warm) async {
110 print('Running $dartApp');
111
112 void processLine(String line) {
113 if (line.contains(_wroteProgram)) {
114 // Show progress
115 stdout
116 ..write('.')
117 ..flush();
118 return;
119 }
120 int index = line.indexOf(_coldStart);
121 if (index >= 0) {
122 cold.add(double.parse(line.substring(index + _coldStart.length)));
123 print('\ncold: ${cold.last}');
124 return;
125 }
126 index = line.indexOf(_warmRun);
127 if (index >= 0) {
128 index = line.indexOf(':', index + _warmRun.length);
129 warm.add(double.parse(line.substring(index + 1)));
130 print('warm: ${warm.last}');
131 return;
132 }
133 }
134
135 String workingDirPath = workingDir.toFilePath();
136 List<String> procArgs = <String>[
137 '-Diterations=$iterations',
138 dartApp.toFilePath()
139 ];
140 procArgs.addAll(args);
141
142 Process process = await Process.start(Platform.executable, procArgs,
143 workingDirectory: workingDirPath);
144 stderr.addStream(process.stderr);
145 StreamSubscription<String> stdOutSubscription;
146 stdOutSubscription = process.stdout
147 .transform(UTF8.decoder)
148 .transform(new LineSplitter())
149 .listen(processLine, onDone: () {
150 stdOutSubscription.cancel();
151 }, onError: (e) {
152 print('Error: $e');
153 stdOutSubscription.cancel();
154 });
155 int code = await process.exitCode;
156 if (code != 0) {
157 throw 'fail: $code';
158 }
159 print('');
160 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/tool/fasta/compile.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698