| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 import datetime | 7 import datetime |
| 8 import math | 8 import math |
| 9 try: | 9 try: |
| 10 from matplotlib.font_manager import FontProperties | 10 from matplotlib.font_manager import FontProperties |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 RunCmd(cmd) | 73 RunCmd(cmd) |
| 74 return time.time() - start | 74 return time.time() - start |
| 75 | 75 |
| 76 def SyncAndBuild(failed_once=False): | 76 def SyncAndBuild(failed_once=False): |
| 77 """Make sure we have the latest version of of the repo, and build it. We | 77 """Make sure we have the latest version of of the repo, and build it. We |
| 78 begin and end standing in DART_INSTALL_LOCATION. | 78 begin and end standing in DART_INSTALL_LOCATION. |
| 79 Args: | 79 Args: |
| 80 failed_once True if we have attempted to build this once before, and we've | 80 failed_once True if we have attempted to build this once before, and we've |
| 81 failed, indicating the build is broken.""" | 81 failed, indicating the build is broken.""" |
| 82 os.chdir(DART_INSTALL_LOCATION) | 82 os.chdir(DART_INSTALL_LOCATION) |
| 83 #Revert our newly built frogsh to prevent conflicts when we update | 83 #Revert our newly built minfrog to prevent conflicts when we update |
| 84 RunCmd(['svn', 'revert', os.path.join(os.getcwd(), 'frog', 'frogsh')]) | 84 RunCmd(['svn', 'revert', os.path.join(os.getcwd(), 'frog', 'minfrog')]) |
| 85 | 85 |
| 86 RunCmd(['gclient', 'sync']) | 86 RunCmd(['gclient', 'sync']) |
| 87 lines = RunCmd([os.path.join('.', 'tools', 'build.py'), '-m', 'release']) | 87 lines = RunCmd([os.path.join('.', 'tools', 'build.py'), '-m', 'release']) |
| 88 os.chdir('frog') | 88 os.chdir('frog') |
| 89 lines += RunCmd([os.path.join('..', 'tools', 'build.py'), '-m', | 89 lines += RunCmd([os.path.join('..', 'tools', 'build.py'), '-m', |
| 90 'debug,release']) | 90 'debug,release']) |
| 91 os.chdir('..') | 91 os.chdir('..') |
| 92 | 92 |
| 93 for line in lines: | 93 for line in lines: |
| 94 if 'BUILD FAILED' in lines: | 94 if 'BUILD FAILED' in lines: |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 os.chdir(DART_INSTALL_LOCATION) | 295 os.chdir(DART_INSTALL_LOCATION) |
| 296 EnsureOutputDirectory(self.result_folder_name) | 296 EnsureOutputDirectory(self.result_folder_name) |
| 297 EnsureOutputDirectory(GRAPH_OUT_DIR) | 297 EnsureOutputDirectory(GRAPH_OUT_DIR) |
| 298 self.RunTests() | 298 self.RunTests() |
| 299 os.chdir(os.path.join('tools', 'testing', 'perf_testing')) | 299 os.chdir(os.path.join('tools', 'testing', 'perf_testing')) |
| 300 | 300 |
| 301 # TODO(efortuna): You will want to make this only use a subset of the files | 301 # TODO(efortuna): You will want to make this only use a subset of the files |
| 302 # eventually. | 302 # eventually. |
| 303 files = os.listdir(self.result_folder_name) | 303 files = os.listdir(self.result_folder_name) |
| 304 | 304 |
| 305 for afile in files: |
| 306 if not afile.startswith('.'): |
| 307 self.ProcessFile(afile) |
| 308 |
| 305 if PERFBOT_MODE: | 309 if PERFBOT_MODE: |
| 306 for afile in files: | |
| 307 if not afile.startswith('.'): | |
| 308 self.ProcessFile(afile) | |
| 309 | |
| 310 self.PlotResults('%s.png' % self.result_folder_name) | 310 self.PlotResults('%s.png' % self.result_folder_name) |
| 311 self.Cleanup(); | 311 self.Cleanup(); |
| 312 | 312 |
| 313 class PerformanceTestRunner(TestRunner): | 313 class PerformanceTestRunner(TestRunner): |
| 314 """Super class for all performance testing.""" | 314 """Super class for all performance testing.""" |
| 315 def __init__(self, result_folder_name, platform_list, platform_type): | 315 def __init__(self, result_folder_name, platform_list, platform_type): |
| 316 super(PerformanceTestRunner, self).__init__(result_folder_name, | 316 super(PerformanceTestRunner, self).__init__(result_folder_name, |
| 317 platform_list, GetVersions(), BENCHMARKS) | 317 platform_list, GetVersions(), BENCHMARKS) |
| 318 self.platform_list = platform_list | 318 self.platform_list = platform_list |
| 319 self.platform_type = platform_type | 319 self.platform_type = platform_type |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 line = '' | 435 line = '' |
| 436 i = 0 | 436 i = 0 |
| 437 revision_num = 0 | 437 revision_num = 0 |
| 438 while '<div id="results">' not in line and i < len(lines): | 438 while '<div id="results">' not in line and i < len(lines): |
| 439 if 'Revision' in line: | 439 if 'Revision' in line: |
| 440 revision_num = int(line.split()[1]) | 440 revision_num = int(line.split()[1]) |
| 441 line = lines[i] | 441 line = lines[i] |
| 442 i += 1 | 442 i += 1 |
| 443 | 443 |
| 444 if i >= len(lines) or revision_num == 0: | 444 if i >= len(lines) or revision_num == 0: |
| 445 # Then this run did not complete. Ignore this tracefile. | 445 # Then this run did not complete. Ignore this tracefile. or in the case of |
| 446 # the smoke test, report an error. |
| 447 if not PERFBOT_MODE: |
| 448 print 'FAIL %s %s' % (browser, version) |
| 449 os.remove(os.path.join(self.result_folder_name, afile)) |
| 446 return | 450 return |
| 447 | 451 |
| 448 line = lines[i] | 452 line = lines[i] |
| 449 i += 1 | 453 i += 1 |
| 450 results = [] | 454 results = [] |
| 451 if line.find('<br>') > -1: | 455 if line.find('<br>') > -1: |
| 452 results = line.split('<br>') | 456 results = line.split('<br>') |
| 453 else: | 457 else: |
| 454 results = line.split('<br />') | 458 results = line.split('<br />') |
| 455 for result in results: | 459 for result in results: |
| 456 name_and_score = result.split(':') | 460 name_and_score = result.split(':') |
| 457 if len(name_and_score) < 2: | 461 if len(name_and_score) < 2: |
| 458 break | 462 break |
| 459 name = name_and_score[0].strip() | 463 name = name_and_score[0].strip() |
| 460 score = name_and_score[1].strip() | 464 score = name_and_score[1].strip() |
| 461 if version == V8: | 465 if version == V8: |
| 462 bench_dict = self.values_dict[browser][V8] | 466 bench_dict = self.values_dict[browser][V8] |
| 463 else: | 467 else: |
| 464 bench_dict = self.values_dict[browser][FROG] | 468 bench_dict = self.values_dict[browser][FROG] |
| 465 bench_dict[name] += [float(score)] | 469 bench_dict[name] += [float(score)] |
| 466 self.revision_dict[browser][version][name] += [revision_num] | 470 self.revision_dict[browser][version][name] += [revision_num] |
| 467 | 471 |
| 468 f.close() | 472 f.close() |
| 469 self.CalculateGeometricMean(browser, version, revision_num) | 473 if not PERFBOT_MODE: |
| 474 print 'PASS' |
| 475 os.remove(os.path.join(self.result_folder_name, afile)) |
| 476 else: |
| 477 self.CalculateGeometricMean(browser, version, revision_num) |
| 470 | 478 |
| 471 def WriteHtml(self, delimiter, rev_nums, label_1, dict_1, label_2, dict_2, | 479 def WriteHtml(self, delimiter, rev_nums, label_1, dict_1, label_2, dict_2, |
| 472 cleanFile=False): | 480 cleanFile=False): |
| 473 #TODO(efortuna) | 481 #TODO(efortuna) |
| 474 pass | 482 pass |
| 475 | 483 |
| 476 | 484 |
| 477 def Cleanup(): | 485 def Cleanup(self): |
| 478 # Kill the zombie chromedriver processes. | 486 # Kill the zombie chromedriver processes. |
| 479 RunCmd(['killall', 'chromedriver']) | 487 RunCmd(['killall', 'chromedriver']) |
| 480 | 488 |
| 481 | 489 |
| 482 class BrowserCorrectnessTestRunner(TestRunner): | 490 class BrowserCorrectnessTestRunner(TestRunner): |
| 483 def __init__(self, test_type, result_folder_name): | 491 def __init__(self, test_type, result_folder_name): |
| 484 super(BrowserCorrectnessTestRunner, self).__init__(result_folder_name, | 492 super(BrowserCorrectnessTestRunner, self).__init__(result_folder_name, |
| 485 GetBrowsers(), [FROG], [CORRECTNESS]) | 493 GetBrowsers(), [FROG], [CORRECTNESS]) |
| 486 self.test_type = test_type | 494 self.test_type = test_type |
| 487 | 495 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 f.close() | 538 f.close() |
| 531 | 539 |
| 532 def PlotResults(self, png_filename): | 540 def PlotResults(self, png_filename): |
| 533 first_time = True | 541 first_time = True |
| 534 for browser in GetBrowsers(): | 542 for browser in GetBrowsers(): |
| 535 self.StyleAndSavePerfPlot('Percentage of language tests passing in ' | 543 self.StyleAndSavePerfPlot('Percentage of language tests passing in ' |
| 536 'different browsers', '% of tests passed', 8, 8, 'lower left', | 544 'different browsers', '% of tests passed', 8, 8, 'lower left', |
| 537 png_filename, [browser], [FROG], [CORRECTNESS], first_time) | 545 png_filename, [browser], [FROG], [CORRECTNESS], first_time) |
| 538 first_time = False | 546 first_time = False |
| 539 | 547 |
| 540 def Cleanup(): | 548 def Cleanup(self): |
| 541 # Kill the zombie chromedriver processes. | 549 # Kill the zombie chromedriver processes. |
| 542 RunCmd(['killall', 'chromedriver']) | 550 RunCmd(['killall', 'chromedriver']) |
| 543 | 551 |
| 544 class CompileTimeAndSizeTestRunner(TestRunner): | 552 class CompileTimeAndSizeTestRunner(TestRunner): |
| 545 """Run tests to determine how long frogsh takes to compile, and the compiled | 553 """Run tests to determine how long minfrog takes to compile, and the compiled |
| 546 file output size of some benchmarking files.""" | 554 file output size of some benchmarking files.""" |
| 547 def __init__(self, result_folder_name): | 555 def __init__(self, result_folder_name): |
| 548 super(CompileTimeAndSizeTestRunner, self).__init__(result_folder_name, | 556 super(CompileTimeAndSizeTestRunner, self).__init__(result_folder_name, |
| 549 [COMMAND_LINE], [FROG], ['Compiling on Dart VM', 'Bootstrapping', | 557 [COMMAND_LINE], [FROG], ['Compiling on Dart VM', 'Bootstrapping', |
| 550 'frogsh', 'swarm', 'total']) | 558 'minfrog', 'swarm', 'total']) |
| 551 self.failure_threshold = {'Compiling on Dart VM' : 1, 'Bootstrapping' : .5, | 559 self.failure_threshold = {'Compiling on Dart VM' : 1, 'Bootstrapping' : .5, |
| 552 'frogsh' : 100, 'swarm' : 100, 'total' : 100} | 560 'minfrog' : 100, 'swarm' : 100, 'total' : 100} |
| 553 | 561 |
| 554 def RunTests(self): | 562 def RunTests(self): |
| 555 os.chdir('frog') | 563 os.chdir('frog') |
| 556 self.trace_file = os.path.join('..', 'tools', 'testing', 'perf_testing', | 564 self.trace_file = os.path.join('..', 'tools', 'testing', 'perf_testing', |
| 557 self.result_folder_name, self.result_folder_name + self.cur_time) | 565 self.result_folder_name, self.result_folder_name + self.cur_time) |
| 558 | 566 |
| 559 self.AddSvnRevisionToTrace(self.trace_file) | 567 self.AddSvnRevisionToTrace(self.trace_file) |
| 560 | 568 |
| 561 elapsed = TimeCmd([os.path.join('.', 'frog.py'), | 569 elapsed = TimeCmd([os.path.join('.', 'frog.py'), '--', |
| 562 '--vm_flags="--compile_all --enable_type_checks --enable_asserts"', | 570 '--out=minfrog', 'minfrog.dart']) |
| 563 '--', '--compile_all', '--enable_type_checks', '--out=frogsh', | 571 RunCmd(['echo', '%f Compiling on Dart VM in production mode in seconds' |
| 564 'frog.dart']) | |
| 565 RunCmd(['echo', '%f Compiling on Dart VM in checked mode in seconds' | |
| 566 % elapsed], self.trace_file, append=True) | 572 % elapsed], self.trace_file, append=True) |
| 567 elapsed = TimeCmd([os.path.join('.', 'frogsh'), '--out=frogsh', | 573 elapsed = TimeCmd([os.path.join('.', 'minfrog'), '--out=minfrog', |
| 568 '--enable_type_checks', 'frog.dart', '--enable_type_checks', | 574 '--warnings_as_errors', 'minfrog.dart', os.path.join('tests', |
| 569 os.path.join('tests', 'hello.dart')]) | 575 'hello.dart')]) |
| 570 if elapsed < self.failure_threshold['Bootstrapping']: | 576 if elapsed < self.failure_threshold['Bootstrapping']: |
| 571 #frogsh didn't compile correctly. Stop testing now, because subsequent | 577 #minfrog didn't compile correctly. Stop testing now, because subsequent |
| 572 #numbers will be meaningless. | 578 #numbers will be meaningless. |
| 573 return | 579 return |
| 574 size = os.path.getsize('frogsh') | 580 size = os.path.getsize('minfrog') |
| 575 RunCmd(['echo', '%f Bootstrapping time in seconds in checked mode' % | 581 RunCmd(['echo', '%f Bootstrapping time in seconds in production mode' % |
| 576 elapsed], self.trace_file, append=True) | 582 elapsed], self.trace_file, append=True) |
| 577 RunCmd(['echo', '%d Generated checked frogsh size' % size], | 583 RunCmd(['echo', '%d Generated checked minfrog size' % size], |
| 578 self.trace_file, append=True) | 584 self.trace_file, append=True) |
| 579 | 585 |
| 580 RunCmd([os.path.join('.', 'frogsh'), ' --out=swarm-result ', | 586 RunCmd([os.path.join('.', 'minfrog'), ' --out=swarm-result ', |
| 581 '--compile-only', os.path.join('..', 'client', 'samples', 'swarm', | 587 '--compile-only', os.path.join('..', 'client', 'samples', 'swarm', |
| 582 'swarm.dart')]) | 588 'swarm.dart')]) |
| 583 swarm_size = 0 | 589 swarm_size = 0 |
| 584 try: | 590 try: |
| 585 swarm_size = os.path.getsize('swarm-result') | 591 swarm_size = os.path.getsize('swarm-result') |
| 586 except OSError: | 592 except OSError: |
| 587 pass #If compilation failed, continue on running other tests. | 593 pass #If compilation failed, continue on running other tests. |
| 588 | 594 |
| 589 RunCmd([os.path.join('.', 'frogsh'), '--out=total-result', | 595 RunCmd([os.path.join('.', 'minfrog'), '--out=total-result', |
| 590 '--compile-only', os.path.join('..', 'client', 'samples', 'total', | 596 '--compile-only', os.path.join('..', 'client', 'samples', 'total', |
| 591 'src', 'Total.dart')]) | 597 'src', 'Total.dart')]) |
| 592 total_size = 0 | 598 total_size = 0 |
| 593 try: | 599 try: |
| 594 total_size = os.path.getsize('total-result') | 600 total_size = os.path.getsize('total-result') |
| 595 except OSError: | 601 except OSError: |
| 596 pass #If compilation failed, continue on running other tests. | 602 pass #If compilation failed, continue on running other tests. |
| 597 | 603 |
| 598 RunCmd(['echo', '%d Generated checked swarm size' % swarm_size], | 604 RunCmd(['echo', '%d Generated checked swarm size' % swarm_size], |
| 599 self.trace_file, append=True) | 605 self.trace_file, append=True) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 630 self.revision_dict[COMMAND_LINE][FROG][metric] += [revision_num] | 636 self.revision_dict[COMMAND_LINE][FROG][metric] += [revision_num] |
| 631 # Fill 0 if compilation failed. | 637 # Fill 0 if compilation failed. |
| 632 if self.values_dict[COMMAND_LINE][FROG][metric][-1] < \ | 638 if self.values_dict[COMMAND_LINE][FROG][metric][-1] < \ |
| 633 self.failure_threshold[metric]: | 639 self.failure_threshold[metric]: |
| 634 self.values_dict[COMMAND_LINE][FROG][metric] += [0] | 640 self.values_dict[COMMAND_LINE][FROG][metric] += [0] |
| 635 self.revision_dict[COMMAND_LINE][FROG][metric] += [revision_num] | 641 self.revision_dict[COMMAND_LINE][FROG][metric] += [revision_num] |
| 636 | 642 |
| 637 f.close() | 643 f.close() |
| 638 | 644 |
| 639 def PlotResults(self, png_filename): | 645 def PlotResults(self, png_filename): |
| 640 self.StyleAndSavePerfPlot('Compiled frogsh Sizes', | 646 self.StyleAndSavePerfPlot('Compiled minfrog Sizes', |
| 641 'Size (in bytes)', 10, 10, 'center', png_filename, [COMMAND_LINE], | 647 'Size (in bytes)', 10, 10, 'center', png_filename, [COMMAND_LINE], |
| 642 [FROG], ['swarm', 'total', 'frogsh']) | 648 [FROG], ['swarm', 'total', 'minfrog']) |
| 643 self.WriteHtml('bar', self.revision_dict[COMMAND_LINE][FROG]['frogsh'], | 649 self.WriteHtml('bar', self.revision_dict[COMMAND_LINE][FROG]['minfrog'], |
| 644 'frogsh size', self.values_dict[COMMAND_LINE][FROG]['frogsh'], '', []) | 650 'minfrog size', self.values_dict[COMMAND_LINE][FROG]['minfrog'], '', []) |
| 645 | 651 |
| 646 self.StyleAndSavePerfPlot('Time to compile and bootstrap', | 652 self.StyleAndSavePerfPlot('Time to compile and bootstrap', |
| 647 'Seconds', 10, 10, 'center', '2' + png_filename, [COMMAND_LINE], [FROG], | 653 'Seconds', 10, 10, 'center', '2' + png_filename, [COMMAND_LINE], [FROG], |
| 648 ['Bootstrapping', 'Compiling on Dart VM']) | 654 ['Bootstrapping', 'Compiling on Dart VM']) |
| 649 self.WriteHtml('baz', | 655 self.WriteHtml('baz', |
| 650 self.revision_dict[COMMAND_LINE][FROG]['Bootstrapping'], | 656 self.revision_dict[COMMAND_LINE][FROG]['Bootstrapping'], |
| 651 'Bootstrapping', self.values_dict[COMMAND_LINE][FROG]['Bootstrapping'], | 657 'Bootstrapping', self.values_dict[COMMAND_LINE][FROG]['Bootstrapping'], |
| 652 'Compiling on Dart VM', | 658 'Compiling on Dart VM', |
| 653 self.values_dict[COMMAND_LINE][FROG]['Compiling on Dart VM']) | 659 self.values_dict[COMMAND_LINE][FROG]['Compiling on Dart VM']) |
| 654 | 660 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 if HasNewCode(): | 712 if HasNewCode(): |
| 707 RunTestSequence(cl, size, language, perf) | 713 RunTestSequence(cl, size, language, perf) |
| 708 else: | 714 else: |
| 709 time.sleep(SLEEP_TIME) | 715 time.sleep(SLEEP_TIME) |
| 710 else: | 716 else: |
| 711 RunTestSequence(cl, size, language, perf) | 717 RunTestSequence(cl, size, language, perf) |
| 712 | 718 |
| 713 if __name__ == '__main__': | 719 if __name__ == '__main__': |
| 714 main() | 720 main() |
| 715 | 721 |
| OLD | NEW |