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

Side by Side Diff: tools/testing/perf_testing/create_graph.py

Issue 8670013: Adding the performance and browser benchmarking script. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
Property Changes:
Added: svn:executable
+ *
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file.
6
7 import datetime
8 import math
9 from matplotlib.font_manager import FontProperties
10 import matplotlib.pyplot as plt
11 import os
12 import platform
13 import shutil
14 import subprocess
15 import time
16 import traceback
17
18 """This script is run hourly to track performance and correctness progress of
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 could we trigger it on each revision change?
Emily Fortuna 2011/11/30 00:37:13 Done.
19 different svn revisions."""
20
21 class TestRunner:
22 """The base clas to provide shared code for different tests we will run and
23 graph."""
24 DART_INSTALL_LOCATION = '/Users/efortuna/perfChart/dart'
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 make it independent - you can derive it from the c
Emily Fortuna 2011/11/30 00:37:13 Done.
25 GCLIENT_LOCATION = '/Users/efortuna/depot_tools/gclient'
26 # True if we have attempted to build this once before, and we've failed, to
27 # indicate if we think the build is likely broken.
28 failed_once = False
29 V8_MEAN = 'V8 Mean'
30 FROG_MEAN = 'frog Mean'
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 (nit) I'd move all these constants to the top leve
Emily Fortuna 2011/11/30 00:37:13 Done.
31
32 def __init__(self, result_folder_name):
33 """Args:
34 result_folder_name the name of the folder where a tracefile of
35 performance results will be stored."""
36 self.result_folder_name = result_folder_name
37 # cur_time is used as a timestamp of when this performance test was run.
38 self.cur_time = str(time.mktime(datetime.datetime.now().timetuple()))
39 self.browsers = ['ff', 'chrome']
40 if platform.system() == 'Windows':
41 self.browsers += ['ie']
42 self.browser_color = {'chrome': 'green', 'ie': 'blue', 'ff': 'red'}
43 self.benchmarks = ['Mandelbrot', 'DeltaBlue', 'Richards', 'NBody',
44 'BinaryTrees', 'Fannkuch', 'Meteor', 'BubbleSort', 'Fibonacci',
45 'Loop', 'Permute', 'Queens', 'QuickSort', 'Recurse', 'Sieve', 'Sum',
46 'Tak', 'Takl', 'Towers', 'TreeSort']
47
48 def style_and_save_perf_plot(self, chart_title, y_axis_label, size_x, size_y,
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 (nit): we tend to use a CamelCase style for functi
Emily Fortuna 2011/11/30 00:37:13 Done.
49 legend_loc, filename):
50 """Sets style preferences for chart boilerplate that is consistent across
51 all charts, and saves the chart as a png.
52 Args:
53 size_x the size of the printed chart, in inches, in the horizontal
54 direction
55 size_y the size of the printed chart, in inches in the vertical direction
56 legend_loc the location of the legend in on the chart. See suitable
57 arguments for the loc argument in matplotlib
58 filename the filename that we want to save the resulting chart as"""
59 plt.xlabel('Revision Number')
60 plt.ylabel(y_axis_label)
61 plt.title(chart_title)
62 fontP = FontProperties()
63 fontP.set_size('small')
64 plt.legend(loc=legend_loc, prop = fontP)
65
66 fig = plt.gcf()
67 fig.set_size_inches(size_x, size_y)
68 fig.savefig(filename)
69
70 @staticmethod
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 you can also move this definition to the top-level
Emily Fortuna 2011/11/30 00:37:13 Done.
71 def run_cmd(string):
72 """Run the specified command and print out any output to stdout.
73 Args:
74 string the command to run"""
75 p = subprocess.Popen(string, shell = True, stdout = subprocess.PIPE,
76 stderr = subprocess.STDOUT, close_fds=True)
77 lines = p.stdout.readlines()
78 for line in lines:
79 print line,
80 return lines
81
82 @staticmethod
83 def sync_and_build():
84 """Make sure we have the latest version of of the repo, and build it. We
85 begin and end standing in TestRunner.DART_INSTALL_LOCATION.
86 Args:
87 should_sync is true if we want to sync to the latest repo version, rather
88 than simply moving to the correct directory."""
89 os.chdir(TestRunner.DART_INSTALL_LOCATION)
90 #Remove our newly built frogsh to prevent conflicts when we update
91 try:
92 os.remove(os.getcwd() + os.path.join('frog', 'frogsh'))
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 or 'svn revert'?
Emily Fortuna 2011/11/30 00:37:13 Done.
93 except OSError:
94 pass
95
96 TestRunner.run_cmd('%s sync' % TestRunner.GCLIENT_LOCATION)
97 lines = TestRunner.run_cmd('%s -m release' % os.path.join('.', 'tools',
98 'build.py'))
99 os.chdir('frog')
100 lines += TestRunner.run_cmd('%s -m debug,release' % os.path.join('..',
101 'tools', 'build.py'))
102 os.chdir('..')
103
104 for line in lines:
105 if '** BUILD FAILED **' in lines:
106 if TestRunner.failed_once:
107 # Someone checked in a broken build! Just stop trying to make it work
108 # and wait for the next hour to try again.
109 print 'FAILED ONCEEEEEE'
110 sys.exit(0)
111 #Remove the xcode directory and attempt to build again. If it still
112 #fails, abort, and try again next hour.
113 out_dir = 'out'
114 if platform.system() == 'Darwin':
115 out_dir = 'xcodebuild'
116 os.remove(os.getcwd() + os.path.join('dart', out_dir, 'Release_ia32'))
117 os.remove(os.getcwd() + os.path.join('dart', 'frog', out_dir,
118 'Release_ia32'))
119 os.remove(os.getcwd() + os.path.join('dart', 'frog', out_dir,
120 'Debug_ia32'))
121 TestRunner.failed_once = True
122 TestRunner.sync_and_build()
123
124 @staticmethod
125 def ensure_output_directory(dir_name):
126 """Test that the listed directory name exists, and if not, create one for
127 our output to be placed."""
128 dir_path = os.path.join(TestRunner.DART_INSTALL_LOCATION, 'tools', 'testing' ,
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 80
Emily Fortuna 2011/11/30 00:37:13 Done.
129 'perf_testing', dir_name)
130 if not os.path.exists(dir_path):
131 os.makedir(dir_path)
132 print 'Creating output directory ', dir_path
133
134 def add_svn_revision_to_trace(self, outfile):
135 """Add the svn version number to the provided tracefile."""
136 p = subprocess.Popen('svn info ', shell = True,
137 stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds=True)
138
139 lines = p.stdout.readlines()
140 for line in lines:
141 if 'Revision' in line:
142 TestRunner.run_cmd('echo "%s" > %s' % (line.strip(), outfile))
143
144
145 def write_html(self, delimiter, rev_nums, label_1, dict_1, label_2, dict_2,
146 cleanFile=False):
147 """Adds an html table to the webpage to display the data values. This method
148 will be removed when we have a nicer way to display data values."""
149 #TODO(efortuna): Take this method out when have finalized where the data is
150 # going to be displayed.
151 f = ''
152 out = ''
153 if cleanFile:
154 f = open('template.html')
155 else:
156 shutil.copy('index.html', 'temp.html')
157 f = open('temp.html')
158 out = open('index.html', 'w')
159 inTable = False
160 for line in f.readlines():
161 if not inTable:
162 out.write(line)
163 if delimiter in line:
164 inTable = not inTable
165 if inTable:
166 out.write('<table border="1"> <tr> <td> svn revision </td>')
167 for revision in rev_nums:
168 out.write('<td>%d</td>' % revision)
169 out.write('</tr>\n<tr><td> %s</td>' % label_1)
170 for perf in dict_1:
171 out.write('<td>%f</td>' % perf)
172 out.write('</tr>\n<tr><td> %s</td>' % label_2)
173 for perf in dict_2:
174 out.write('<td>%f</td>' % perf)
175 out.write('</tr> </table>')
176
177 def calculate_geometric_mean(self, bench_dict_1, bench_dict_2):
178 """Calculate the aggregate geometric mean for V8 and frog benchmark sets,
179 given two benchmark dictionaries."""
180 frog_geo_mean = 0
181 v8_geo_mean = 0
182 for benchmark in self.benchmarks:
183 v8_geo_mean += math.log(bench_dict_1[benchmark][
184 len(bench_dict_1[benchmark]) - 1])
185 frog_geo_mean += math.log(bench_dict_2[benchmark][
186 len(bench_dict_2[benchmark]) - 1])
187
188 bench_dict_1[TestRunner.V8_MEAN] += \
189 [math.pow(math.e, v8_geo_mean / len(self.benchmarks))]
190 bench_dict_2[TestRunner.FROG_MEAN] += \
191 [math.pow(math.e, frog_geo_mean / len(self.benchmarks))]
192
193 def run(self):
194 """Run the benchmarks/tests from the command line and plot the
195 results."""
196 plt.cla() # cla = clear current axes
197 os.chdir(TestRunner.DART_INSTALL_LOCATION)
198 TestRunner.ensure_output_directory(self.result_folder_name)
199 self.run_tests()
200 os.chdir(os.path.join('tools', 'testing', 'perf_testing'))
201
202 # TODO(efortuna): You will want to make this only use a subset of the files
203 # eventually.
204 files = os.listdir(self.result_folder_name)
205
206 for afile in files:
207 if not afile.startswith('.'):
208 self.process_file(afile)
209 self.plot_results('%s.png' % self.result_folder_name)
210
211 class CommandLinePerformanceTestRunner(TestRunner):
212 """Run performance tests from the command line."""
213
214 def __init__(self, result_folder_name):
215 TestRunner.__init__(self, result_folder_name)
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 use 'super'? (there are some examples in architect
Emily Fortuna 2011/11/30 00:37:13 Done.
216 self.revision_nums = dict()
217 self.bench_dict_js = dict()
218 self.bench_dict_frog = dict()
219 for benchmark in self.benchmarks:
220 self.bench_dict_js[benchmark] = []
221 self.bench_dict_frog[benchmark] = []
222 self.bench_dict_js[TestRunner.V8_MEAN] = []
223 self.bench_dict_frog[TestRunner.FROG_MEAN] = []
224 self.revision_nums['js'] = []
225 self.revision_nums['frog'] = []
226
227 def plot_all_perf(self, png_filename):
228 """Create a plot that shows the performance changes of individual benchmarks
229 run by V8 and generated by frog, over svn history."""
230 markers = ['o', '.', 's', 'v', '>', '<', '^']
231 #mfc = marker face color. Bad naming convention to match the named parameter
232 # in matplotlib.plot(...).
233 mfc = ['red', 'yellow', 'black']
234 bench_style = dict()
235 i = 0
236 j = 0
237 for benchmark in self.benchmarks:
238 bench_style[benchmark] = (markers[i], mfc[j])
239 i += 1
240 if i >= len(markers):
241 j += 1
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 what if you have > than 21 benchmarks?
Emily Fortuna 2011/11/30 00:37:13 Done.
242 i=0
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 Alternatively you could write the index calculatio
Emily Fortuna 2011/11/30 00:37:13 Done.
243
244 for benchmark in self.benchmarks:
245 style = bench_style[benchmark]
Siggi Cherem (dart-lang) 2011/11/23 20:00:29 instead of using style[0] below, you could also us
Emily Fortuna 2011/11/30 00:37:13 Done.
246 plt.plot(self.revision_nums['js'], self.bench_dict_js[benchmark],
247 color='blue', marker=style[0], mfc=style[1],
248 label='%s-js' % benchmark)
249 plt.plot(self.revision_nums['frog'], self.bench_dict_frog[benchmark],
250 color='green', marker=style[0], mfc=style[1],
251 label='%s-frog' % benchmark)
252
253 self.style_and_save_perf_plot('Performance of benchmarks over time',
254 'Speed (bigger = better)', 16, 14, 'lower left', png_filename)
255
256 def plot_avg_perf(self, png_filename):
257 """Generate a plot that shows the performance changes of the geomentric mean
258 of V8 and frog benchmark performance over svn history."""
259 plt.cla() # cla = clear current axes
260 plt.plot(self.revision_nums['js'],
261 self.bench_dict_js[TestRunner.V8_MEAN], color = 'blue',
262 label=TestRunner.V8_MEAN, linewidth=2.0)
263 plt.plot(self.revision_nums['frog'],
264 self.bench_dict_frog[TestRunner.FROG_MEAN], color='green',
265 label=PerformanceTestRunner.FROG_MEAN, linewidth=2.0)
266 self.style_and_save_perf_plot('Geometric Mean of benchmark performance',
267 'Speed (bigger = better)', 16, 5, 'center', png_filename)
268 self.write_html('table',
269 self.revision_nums['js'],
270 'V8 mean', self.bench_dict_js[TestRunner.V8_MEAN],
271 'Frog mean', self.bench_dict_frog[TestRunner.FROG_MEAN],
272 True)
273
274 def plot_results(self, png_filename):
275 self.plot_all_perf(png_filename)
276 self.plot_avg_perf('2' + png_filename)
277
278 def process_file(self, afile):
279 """Pull all the relevant information out of a given tracefile.
280
281 Args:
282 afile is the filename string we will be processing."""
283 f = open(os.path.join(self.result_folder_name, afile))
284 tabulate_data = False
285 for line in f.readlines():
286 if 'Revision' in line:
287 revision_num = int(line.split()[1])
288 self.revision_nums['js'] += [revision_num]
289 self.revision_nums['frog'] += [revision_num]
290 elif 'Benchmark' in line:
291 tabulate_data = True
292 elif tabulate_data:
293 tokens = line.split()
294 if len(tokens) < 4 or tokens[0] not in self.benchmarks:
295 #Done tabulating data.
296 break
297 v8_value = float(tokens[1])
298 frog_value = float(tokens[3])
299 if v8_value == 0 or frog_value == 0:
300 #Then there was an error when this performance test was run. Do not
301 #count it in our numbers.
302 self.revision_nums['js'].pop()
303 self.revision_nums['frog'].pop()
304 return
305 self.bench_dict_js[tokens[0]] += [v8_value]
306 self.bench_dict_frog[tokens[0]] += [frog_value]
307 f.close()
308
309 self.calculate_geometric_mean(self.bench_dict_js, self.bench_dict_frog)
310
311 def run_tests(self):
312 """Run a performance test on our updated system."""
313 os.chdir('frog')
314 file_path = os.path.join('..', 'tools', 'testing', 'perf_testing',
315 self.result_folder_name, 'result')
316 TestRunner.run_cmd('python %s > %s%s' % (os.path.join('benchmarks',
317 'perf_tests.py'), file_path, self.cur_time))
318 os.chdir('..')
319
320
321 class BrowserPerformanceTestRunner(TestRunner):
322 """Runs performance tests, in the browser."""
323
324 def __init__(self, result_folder_name):
325 TestRunner.__init__(self, result_folder_name)
326 self.revision_nums = dict()
327 self.bench_dict_js = dict()
328 self.bench_dict_frog = dict()
329 for browser in self.browsers:
330 self.revision_nums[browser] = dict()
331 self.bench_dict_js[browser] = dict()
332 self.bench_dict_frog[browser] = dict()
333 for benchmark in self.benchmarks:
334 self.bench_dict_js[browser][benchmark] = []
335 self.bench_dict_frog[browser][benchmark] = []
336 self.bench_dict_js[browser][TestRunner.V8_MEAN] = []
337 self.bench_dict_frog[browser][TestRunner.FROG_MEAN] = []
338 self.revision_nums[browser]['js'] = []
339 self.revision_nums[browser]['frog'] = []
340
341 def run_tests(self):
342 """Run a performance test in the browser."""
343 os.chdir('frog')
344 self.run_cmd('python benchmarks/make_web_benchmarks.py')
345 os.chdir('..')
346
347 for browser in self.browsers:
348 for version in ['js', 'frog']:
349 self.add_svn_revision_to_trace(os.path.join('tools', 'testing',
350 'perf_testing', self.result_folder_name,
351 'perf-%s-%s-%s' % (self.cur_time, browser, version)))
352 TestRunner.run_cmd('python %s %s %s 1000 perfTest >> %s' %
353 (os.path.join('tools', 'testing', 'run_selenium.py'),
354 os.path.join(os.getcwd(), 'internal', 'browserBenchmarks',
355 'benchmark_page_%s.html' % version),
356 browser,
357 os.path.join('tools', 'testing', 'perf_testing',
358 self.result_folder_name, 'perf-%s-%s-%s' % (self.cur_time, browser,
359 version))))
360
361 def process_file(self, afile):
362 """Comb through the html to find the performance results."""
363 parts = afile.split('-')
364 browser = parts[2]
365 version = parts[3]
366 f = open(os.path.join(self.result_folder_name, afile))
367 lines = f.readlines()
368 line = ''
369 i = 0
370 while '<div id="results">' not in line:
371 line = lines[i]
372 i += 1
373
374 line = lines[i]
375 i += 1
376 results = []
377 if line.find('<br>') > -1:
378 results = line.split('<br>')
379 else:
380 results = line.split('<br />')
381 for result in results:
382 name_and_score = result.split(':')
383 if len(name_and_score) < 2:
384 break
385 name = name_and_score[0].strip()
386 score = name_and_score[1].strip()
387 if version == 'js':
388 bench_dict = self.bench_dict_js[browser]
389 else:
390 bench_dict = self.bench_dict_frog[browser]
391 bench_dict[name] += [score]
392
393 while i < len(lines):
394 if 'Revision' in line:
395 self.revision_nums[browser][version] = int(line.split()[1])
396 line = lines[i]
397 i += 1
398 f.close()
399 self.calculate_geometric_mean(bench_dict_js[browser],
400 bench_dict_frog[browser])
401
402 def plot_results(self, png_filename):
403 """Generate a plot that shows the performance changes of the geomentric mean
404 of V8 and frog benchmark performance over svn history."""
405 plt.cla() # cla = clear current axes
406 for browser in self.browsers:
407 plt.cla() # cla = clear current axes
408 plt.plot(self.revision_nums[browser]['js'],
409 self.bench_dict_js[browser][TestRunner.V8_MEAN],
410 color = self.browser_color[browser],
411 label=TestRunner.V8_MEAN + '-' + browser, marker='s', linewidth=2.0)
412 plt.plot(self.revision_nums[browser]['frog'],
413 self.bench_dict_frog[browser][TestRunner.FROG_MEAN],
414 color=self.browser_color[browser], marker='o',
415 label=TestRunner.FROG_MEAN + '-' + browser, linewidth=2.0)
416 self.style_and_save_perf_plot('Geometric Mean of benchmark performance',
417 'Speed (bigger = better)', 16, 5, 'center', png_filename)
418 #self.write_html('table',
419 # self.revision_nums['js'],
420 # 'V8 mean', self.bench_dict_js[TestRunner.V8_MEAN],
421 # 'Frog mean', self.bench_dict_frog[TestRunner.FROG_MEAN],
422 # True)
423
424
425 def write_html(self, delimiter, rev_nums, label_1, dict_1, label_2, dict_2,
426 cleanFile=False):
427 #TODO(efortuna)
428 pass
429
430 class BrowserCorrectnessTestRunner(TestRunner):
431 def __init__(self, test_type, result_folder_name):
432 TestRunner.__init__(self, result_folder_name)
433 self.test_type = test_type
434
435 self.passing = dict()
436 self.revision_nums = dict()
437 for browser in self.browsers:
438 self.passing[browser] = []
439 self.revision_nums[browser] = []
440
441 def run_tests(self):
442 """Run a test of the latest svn revision."""
443 for browser in self.browsers:
444 current_file = 'correctness%s-%s' % (self.cur_time, browser)
445 current_file_path = os.path.join('tools', 'testing',
446 'perf_testing', self.result_folder_name, current_file)
447 self.add_svn_revision_to_trace(current_file_path)
448 TestRunner.run_cmd(os.path.join('.', 'tools', 'test.py') +
449 ' --component=webdriver --flag=%s --report --timeout=20 ' % browser +
450 '--progress=color --mode=release -j1 %s >>' % self.test_type +
451 current_file_path)
452
453 def process_file(self, afile):
454 """Given a trace file, extract all the relevant information out of it to
455 determine the number of correctly passing tests.
456
457 Arguments:
458 afile the filename string"""
459 browser = afile.rpartition('-')[2]
460 f = open(os.path.join(self.result_folder_name, afile))
461 revision_num = 1
462 lines = f.readlines()
463 total_tests = 0
464 num_failed = 0
465 expect_fail = 0
466 for line in lines:
467 if 'Total:' in line:
468 total_tests = int(line.split()[1])
469 if 'will be skipped' in line:
470 total_tests -= int(line.split()[1])
471 if 'we should fix' in line:
472 expect_fail += int(line.split()[1])
473 if 'Revision' in line:
474 revision_num = int(line.split()[1])
475 if '--- TIMEOUT ---' in line or 'FAIL:' in line or 'PASS' in line:
476 # (A printed out 'PASS' indicates we incorrectly passed a negative
477 # test.)
478 num_failed += 1
479
480 self.revision_nums[browser] += [revision_num]
481 self.passing[browser] += [100.0 * (((float)(total_tests - (expect_fail +
482 num_failed))) /total_tests)]
483 f.close()
484
485 def plot_results(self, png_filename):
486 for browser in self.browsers:
487 plt.plot(self.revision_nums[browser], self.passing[browser],
488 color=self.browser_color[browser], label=browser)
489 self.style_and_save_perf_plot('Percentage of language tests passing in '
490 'different browsers', '% of tests passed', 8, 8, 'lower left',
491 png_filename)
492
493
494 class CompileTimeAndSizeTestRunner(TestRunner):
495 """Run tests to determine how long frogsh takes to compile, and the compiled
496 file output size of some benchmarking files."""
497 def __init__(self, result_folder_name):
498 TestRunner.__init__(self, result_folder_name)
499 self.metrics = ['Compiling on Dart VM', 'Bootstrapping', 'frogsh', 'swarm',
500 'total']
501 self.revision_nums = []
502 self.metric_dict = dict()
503 self.failure_threshold = {'Compiling on Dart VM' : 1, 'Bootstrapping' : .5,
504 'frogsh' : 100, 'swarm' : 100, 'total' : 100}
505 for metric in self.metrics:
506 self.metric_dict[metric] = []
507
508 def time_cmd(self, cmd):
509 start = time.time()
510 self.run_cmd(cmd)
511 return time.time() - start
512
513 def run_tests(self):
514 os.chdir('frog')
515 current_file_path = os.path.join('..', 'tools', 'testing', 'perf_testing',
516 self.result_folder_name, self.result_folder_name + self.cur_time)
517
518 self.add_svn_revision_to_trace(current_file_path)
519
520 elapsed = self.time_cmd(os.path.join('.', 'frog.py') +
521 ' --vm_flags="--compile_all --enable_type_checks --enable_asserts" --'
522 ' --compile_all --enable_type_checks --out=frogsh frog.dart')
523 self.run_cmd('echo "%f Compiling on Dart VM in checked mode in' % elapsed +
524 ' seconds" >> %s' % current_file_path)
525 self.run_cmd('chmod +x frogsh')
526 elapsed = self.time_cmd(os.path.join('.', 'frogsh') + ' --out=frogsh '
527 '--enable_type_checks frog.dart --enable_type_checks ' +
528 os.path.join('tests', 'hello.dart'))
529 if elapsed < self.failure_threshold['Bootstrapping']:
530 #frogsh didn't compile correctly. Stop testing now, because subsequent
531 #numbers will be meaningless.
532 return
533 size = os.path.getsize('frogsh')
534 self.run_cmd('echo "%f Bootstrapping time in seconds in checked mode"' %
535 elapsed + ' >> %s' % current_file_path)
536 self.run_cmd('echo "%d Generated checked frogsh size "' % size +
537 ' >> %s' % current_file_path)
538
539 self.run_cmd(os.path.join('.', 'frogsh') + ' --out=swarm-result '
540 '--compile-only ' + os.path.join('..', 'client', 'samples', 'swarm',
541 'swarm.dart'))
542 swarm_size = 0
543 try:
544 swarm_size = os.path.getsize('swarm-result')
545 except OSError:
546 pass #If compilation failed, continue on running other tests.
547
548 self.run_cmd(os.path.join('.', 'frogsh') + ' --out=total-result '
549 '--compile-only ' + os.path.join('..', 'client', 'samples', 'total',
550 'src', 'Total.dart'))
551 total_size = 0
552 try:
553 total_size = os.path.getsize('total-result')
554 except OSError:
555 pass #If compilation failed, continue on running other tests.
556
557 self.run_cmd('echo "%d Generated checked swarm size "' % swarm_size +
558 ' >> %s' % current_file_path)
559
560 self.run_cmd('echo "%d Generated checked total size "' % total_size +
561 ' >> %s' % current_file_path)
562 os.chdir('..')
563
564 def process_file(self, afile):
565 """Pull all the relevant information out of a given tracefile.
566
567 Args:
568 afile is the filename string we will be processing."""
569 f = open(os.path.join(self.result_folder_name, afile))
570 tabulate_data = False
571 had_version_number = False
572 for line in f.readlines():
573 tokens = line.split()
574 if 'Revision' in line:
575 had_version_number = True
576 revision_num = int(line.split()[1])
577 self.revision_nums += [revision_num]
578 else:
579 for metric in self.metrics:
580 if metric in line:
581 num = tokens[0]
582 if num.find('.') == -1:
583 num = int(num)
584 else:
585 num = float(num)
586 self.metric_dict[metric] += [num]
587
588 for metric in self.metrics:
589 # Fill 0 if compilation failed.
590 if len(self.revision_nums) != len(self.metric_dict[metric]) \
591 or self.metric_dict[metric][-1] < self.failure_threshold[metric]:
592 if len(self.revision_nums) == len(self.metric_dict[metric]) and \
593 self.metric_dict[metric][-1] < self.failure_threshold[metric]:
594 self.metric_dict[metric].pop()
595 self.metric_dict[metric] += [0]
596 f.close()
597
598 def plot_results(self, png_filename):
599 plt.cla() # cla = clear current axes
600 plt.plot(self.revision_nums, self.metric_dict['swarm'],
601 color = 'blue', label='swarm')
602 plt.plot(self.revision_nums, self.metric_dict['total'],
603 color = 'red', label='total')
604 self.style_and_save_perf_plot('Compiled Swarm and Total Sizes',
605 'Size (in bytes)', 10, 10, 'center', png_filename)
606 self.write_html('foo', self.revision_nums, 'swarm size',
607 self.metric_dict['swarm'], 'total size', self.metric_dict['total'])
608
609 plt.cla() # cla = clear current axes
610 plt.plot(self.revision_nums, self.metric_dict['frogsh'],
611 color = 'green', label='frogsh')
612 self.style_and_save_perf_plot('Compiled frogsh Sizes',
613 'Size (in bytes)', 10, 10, 'center', '2' + png_filename)
614 self.write_html('bar', self.revision_nums, 'frogsh size',
615 self.metric_dict['frogsh'], '', [])
616
617 plt.cla() # cla = clear current axes
618 plt.plot(self.revision_nums, self.metric_dict['Bootstrapping'],
619 color='green', label='bootstrapping')
620 plt.plot(self.revision_nums, self.metric_dict['Compiling on Dart VM'],
621 color='red', label='compiling with Dart VM')
622 self.style_and_save_perf_plot('Time to compile and bootstrap',
623 'Seconds', 10, 10, 'center', '3' + png_filename)
624 self.write_html('baz', self.revision_nums, 'Bootstrapping',
625 self.metric_dict['Bootstrapping'], 'Compiling on Dart VM',
626 self.metric_dict['Compiling on Dart VM'])
627
628
629 def main():
630 TestRunner.sync_and_build()
631 CommandLinePerformanceTestRunner('cl-results').run()
632 CompileTimeAndSizeTestRunner('code-time-size').run()
633 BrowserCorrectnessTestRunner('language', 'browser-correctness').run()
634 BrowserPerformanceTestRunner('browser-perf').run()
635
636 if __name__ == '__main__':
637 main()
638
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698