Chromium Code Reviews| 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 getpass | 8 import getpass |
| 9 import math | 9 import math |
| 10 try: | 10 try: |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 methods that many Tester objects use. Any class that would like to be a | 377 methods that many Tester objects use. Any class that would like to be a |
| 378 TesterVisitor must implement the run_tests() method.""" | 378 TesterVisitor must implement the run_tests() method.""" |
| 379 | 379 |
| 380 def __init__(self, test): | 380 def __init__(self, test): |
| 381 self.test = test | 381 self.test = test |
| 382 | 382 |
| 383 def prepare(self): | 383 def prepare(self): |
| 384 """Perform any initial setup required before the test is run.""" | 384 """Perform any initial setup required before the test is run.""" |
| 385 pass | 385 pass |
| 386 | 386 |
| 387 def add_svn_revision_to_trace(self, outfile): | 387 def add_svn_revision_to_trace(self, outfile, browser = None): |
| 388 """Add the svn version number to the provided tracefile.""" | 388 """Add the svn version number to the provided tracefile.""" |
| 389 def search_for_revision(svn_info_command): | 389 def search_for_revision(svn_info_command): |
| 390 p = subprocess.Popen(svn_info_command, stdout = subprocess.PIPE, | 390 p = subprocess.Popen(svn_info_command, stdout = subprocess.PIPE, |
| 391 stderr = subprocess.STDOUT, shell = | 391 stderr = subprocess.STDOUT, shell = |
| 392 self.test.test_runner.has_shell) | 392 self.test.test_runner.has_shell) |
| 393 output, _ = p.communicate() | 393 output, _ = p.communicate() |
| 394 for line in output.split('\n'): | 394 for line in output.split('\n'): |
| 395 if 'Revision' in line: | 395 if 'Revision' in line: |
| 396 self.test.test_runner.run_cmd(['echo', line.strip()], outfile) | 396 self.test.test_runner.run_cmd(['echo', line.strip()], outfile) |
| 397 return True | 397 return True |
| 398 return False | 398 return False |
| 399 | 399 |
| 400 if not search_for_revision(['svn', 'info']): | 400 def get_dartium_revision(): |
| 401 version_file_name = os.path.join(DART_INSTALL_LOCATION, 'client', 'tests', | |
| 402 'dartium', 'LAST_VERSION') | |
| 403 version_file = open(version_file_name, 'r') | |
| 404 version = version_file.read().split('.')[-2] | |
| 405 version_file.close() | |
| 406 return version | |
| 407 | |
| 408 if browser and browser == 'dartium': | |
| 409 revision = get_dartium_revision() | |
| 410 self.test.test_runner.run_cmd(['echo', 'Revision: ' + revision], outfile) | |
|
Emily Fortuna
2012/04/16 19:22:15
Do you want to print out a slightly different outp
| |
| 411 elif not search_for_revision(['svn', 'info']): | |
| 401 if not search_for_revision(['git', 'svn', 'info']): | 412 if not search_for_revision(['git', 'svn', 'info']): |
| 402 self.test.test_runner.run_cmd(['echo', 'Revision: unknown'], outfile) | 413 self.test.test_runner.run_cmd(['echo', 'Revision: unknown'], outfile) |
| 403 | 414 |
| 404 | 415 |
| 405 class Processor(object): | 416 class Processor(object): |
| 406 """The base level vistor class that processes tests. It contains convenience | 417 """The base level vistor class that processes tests. It contains convenience |
| 407 methods that many File Processor objects use. Any class that would like to be | 418 methods that many File Processor objects use. Any class that would like to be |
| 408 a ProcessorVisitor must implement the process_file() method.""" | 419 a ProcessorVisitor must implement the process_file() method.""" |
| 409 | 420 |
| 410 def __init__(self, test): | 421 def __init__(self, test): |
| 411 self.test = test | 422 self.test = test |
| 412 | 423 |
| 413 def prepare(self): | 424 def prepare(self): |
| 414 """Perform any initial setup required before the test is run.""" | 425 """Perform any initial setup required before the test is run.""" |
| 415 pass | 426 pass |
| 416 | 427 |
| 417 def calculate_geometric_mean(self, platform, variant, svn_revision): | 428 def calculate_geometric_mean(self, platform, variant, svn_revision): |
| 418 """Calculate the aggregate geometric mean for JS and frog benchmark sets, | 429 """Calculate the aggregate geometric mean for JS and frog benchmark sets, |
| 419 given two benchmark dictionaries.""" | 430 given two benchmark dictionaries.""" |
| 420 geo_mean = 0 | 431 geo_mean = 0 |
| 421 for benchmark in self.test.values_list: | 432 for benchmark in self.test.values_list: |
| 422 geo_mean += math.log(self.test.values_dict[platform][variant][benchmark][ | 433 try: |
| 423 len(self.test.values_dict[platform][variant][benchmark]) - 1]) | 434 geo_mean += math.log(self.test.values_dict[platform][variant][benchmark] [ |
|
Emily Fortuna
2012/04/16 19:22:15
Also, why add the try/pass? If you're getting an e
vsm
2012/04/16 20:41:08
Ahh, I meant to clean this up. Because we're skip
Emily Fortuna
2012/04/16 20:50:17
That can work.
vsm
2012/04/16 22:02:58
Done. PTAL.
On 2012/04/16 20:50:17, Emily Fortuna
| |
| 435 len(self.test.values_dict[platform][variant][benchmark]) - 1]) | |
| 436 except IndexError: | |
| 437 pass | |
| 424 | 438 |
| 425 self.test.values_dict[platform][variant]['Geo-Mean'] += \ | 439 self.test.values_dict[platform][variant]['Geo-Mean'] += \ |
| 426 [math.pow(math.e, geo_mean / len(self.test.values_list))] | 440 [math.pow(math.e, geo_mean / len(self.test.values_list))] |
| 427 self.test.revision_dict[platform][variant]['Geo-Mean'] += [svn_revision] | 441 self.test.revision_dict[platform][variant]['Geo-Mean'] += [svn_revision] |
| 428 | 442 |
| 429 | 443 |
| 430 class Grapher(object): | 444 class Grapher(object): |
| 431 """The base level visitor class that generates graphs for data. It contains | 445 """The base level visitor class that generates graphs for data. It contains |
| 432 convenience methods that many Grapher objects use. Any class that would like | 446 convenience methods that many Grapher objects use. Any class that would like |
| 433 to be a GrapherVisitor must implement the plot_results() method.""" | 447 to be a GrapherVisitor must implement the plot_results() method.""" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 [revision_num] | 661 [revision_num] |
| 648 self.test.values_dict['commandline']['frog'][benchmark] += \ | 662 self.test.values_dict['commandline']['frog'][benchmark] += \ |
| 649 [frog_value] | 663 [frog_value] |
| 650 f.close() | 664 f.close() |
| 651 | 665 |
| 652 self.calculate_geometric_mean('commandline', 'frog', revision_num) | 666 self.calculate_geometric_mean('commandline', 'frog', revision_num) |
| 653 self.calculate_geometric_mean('commandline', 'js', revision_num) | 667 self.calculate_geometric_mean('commandline', 'js', revision_num) |
| 654 | 668 |
| 655 | 669 |
| 656 class BrowserTester(Tester): | 670 class BrowserTester(Tester): |
| 657 # TODO(vsm): Add Dartium. | |
| 658 @staticmethod | 671 @staticmethod |
| 659 def get_browsers(): | 672 def get_browsers(): |
| 660 browsers = ['ff', 'chrome'] | 673 browsers = ['dartium', 'ff', 'chrome'] |
| 674 has_shell = False | |
| 661 if platform.system() == 'Darwin': | 675 if platform.system() == 'Darwin': |
| 662 browsers += ['safari'] | 676 browsers += ['safari'] |
| 663 if platform.system() == 'Windows': | 677 if platform.system() == 'Windows': |
| 664 browsers += ['ie'] | 678 browsers += ['ie'] |
| 679 has_shell = True | |
| 680 if 'dartium' in browsers: | |
| 681 # Fetch it if necessary. | |
| 682 get_dartium = ['python', | |
| 683 os.path.join(DART_INSTALL_LOCATION, 'tools', 'get_drt.py'), | |
| 684 '--dartium'] | |
| 685 # TODO(vsm): It's inconvenient that run_cmd isn't in scope here. | |
| 686 # Perhaps there is a better place to put that or this. | |
| 687 subprocess.Popen(get_dartium, shell=has_shell) | |
| 665 return browsers | 688 return browsers |
| 666 | 689 |
| 667 | 690 |
| 668 class CommonBrowserTest(RuntimePerformanceTest): | 691 class CommonBrowserTest(RuntimePerformanceTest): |
| 669 """Runs this basic performance tests (Benchpress, some V8 benchmarks) in the | 692 """Runs this basic performance tests (Benchpress, some V8 benchmarks) in the |
| 670 browser.""" | 693 browser.""" |
| 671 | 694 |
| 672 def __init__(self, test_runner): | 695 def __init__(self, test_runner): |
| 673 """Args: | 696 """Args: |
| 674 test_runner: Reference to the object that notifies us when to run.""" | 697 test_runner: Reference to the object that notifies us when to run.""" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 696 os.chdir('frog') | 719 os.chdir('frog') |
| 697 self.test.test_runner.run_cmd(['python', os.path.join('benchmarks', | 720 self.test.test_runner.run_cmd(['python', os.path.join('benchmarks', |
| 698 'make_web_benchmarks.py')]) | 721 'make_web_benchmarks.py')]) |
| 699 os.chdir('..') | 722 os.chdir('..') |
| 700 | 723 |
| 701 for browser in BrowserTester.get_browsers(): | 724 for browser in BrowserTester.get_browsers(): |
| 702 for version in self.test.versions: | 725 for version in self.test.versions: |
| 703 self.test.trace_file = os.path.join( | 726 self.test.trace_file = os.path.join( |
| 704 'tools', 'testing', 'perf_testing', self.test.result_folder_name, | 727 'tools', 'testing', 'perf_testing', self.test.result_folder_name, |
| 705 'perf-%s-%s-%s' % (self.test.cur_time, browser, version)) | 728 'perf-%s-%s-%s' % (self.test.cur_time, browser, version)) |
| 706 self.add_svn_revision_to_trace(self.test.trace_file) | 729 self.add_svn_revision_to_trace(self.test.trace_file, browser) |
| 707 file_path = os.path.join( | 730 file_path = os.path.join( |
| 708 os.getcwd(), 'internal', 'browserBenchmarks', | 731 os.getcwd(), 'internal', 'browserBenchmarks', |
| 709 'benchmark_page_%s.html' % version) | 732 'benchmark_page_%s.html' % version) |
| 710 self.test.test_runner.run_cmd( | 733 self.test.test_runner.run_cmd( |
| 711 ['python', os.path.join('tools', 'testing', 'run_selenium.py'), | 734 ['python', os.path.join('tools', 'testing', 'run_selenium.py'), |
| 712 '--out', file_path, '--browser', browser, | 735 '--out', file_path, '--browser', browser, |
| 713 '--timeout', '600', '--mode', 'perf'], self.test.trace_file, | 736 '--timeout', '600', '--mode', 'perf'], self.test.trace_file, |
| 714 append=True) | 737 append=True) |
| 715 | 738 |
| 716 class CommonBrowserFileProcessor(Processor): | 739 class CommonBrowserFileProcessor(Processor): |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 dromaeo_path = os.path.join('samples', 'third_party', 'dromaeo') | 875 dromaeo_path = os.path.join('samples', 'third_party', 'dromaeo') |
| 853 current_path = os.getcwd() | 876 current_path = os.getcwd() |
| 854 os.chdir(dromaeo_path) | 877 os.chdir(dromaeo_path) |
| 855 self.test.test_runner.run_cmd(['python', 'generate_frog_tests.py']) | 878 self.test.test_runner.run_cmd(['python', 'generate_frog_tests.py']) |
| 856 os.chdir(current_path) | 879 os.chdir(current_path) |
| 857 | 880 |
| 858 versions = DromaeoTester.get_dromaeo_versions() | 881 versions = DromaeoTester.get_dromaeo_versions() |
| 859 | 882 |
| 860 for browser in BrowserTester.get_browsers(): | 883 for browser in BrowserTester.get_browsers(): |
| 861 for version_name in versions: | 884 for version_name in versions: |
| 885 if browser == 'dartium' and version_name == 'js': | |
| 886 # TODO(vsm): This avoids a bug in 32-bit Chrome (dartium) | |
| 887 # running JS dromaeo. | |
| 888 continue | |
| 862 version = DromaeoTest.DromaeoPerfTester.get_dromaeo_url_query( | 889 version = DromaeoTest.DromaeoPerfTester.get_dromaeo_url_query( |
| 863 version_name) | 890 browser, version_name) |
| 864 self.test.trace_file = os.path.join( | 891 self.test.trace_file = os.path.join( |
| 865 'tools', 'testing', 'perf_testing', self.test.result_folder_name, | 892 'tools', 'testing', 'perf_testing', self.test.result_folder_name, |
| 866 'dromaeo-%s-%s-%s' % (self.test.cur_time, browser, version_name)) | 893 'dromaeo-%s-%s-%s' % (self.test.cur_time, browser, version_name)) |
| 867 self.add_svn_revision_to_trace(self.test.trace_file) | 894 self.add_svn_revision_to_trace(self.test.trace_file, browser) |
| 868 file_path = os.path.join(os.getcwd(), dromaeo_path, | 895 file_path = os.path.join(os.getcwd(), dromaeo_path, |
| 869 'index-js.html?%s' % version) | 896 'index-js.html?%s' % version) |
| 870 self.test.test_runner.run_cmd( | 897 self.test.test_runner.run_cmd( |
| 871 ['python', os.path.join('tools', 'testing', 'run_selenium.py'), | 898 ['python', os.path.join('tools', 'testing', 'run_selenium.py'), |
| 872 '--out', file_path, '--browser', browser, | 899 '--out', file_path, '--browser', browser, |
| 873 '--timeout', '600', '--mode', 'dromaeo'], self.test.trace_file, | 900 '--timeout', '600', '--mode', 'dromaeo'], self.test.trace_file, |
| 874 append=True) | 901 append=True) |
| 875 | 902 |
| 876 @staticmethod | 903 @staticmethod |
| 877 def get_dromaeo_url_query(version): | 904 def get_dromaeo_url_query(browser, version): |
| 905 if browser == 'dartium': | |
| 906 version = version.replace('frog', 'dart') | |
| 878 version = version.replace('_','&') | 907 version = version.replace('_','&') |
| 879 tags = DromaeoTester.get_valid_dromaeo_tags() | 908 tags = DromaeoTester.get_valid_dromaeo_tags() |
| 880 return '|'.join([ '%s&%s' % (version, tag) for tag in tags]) | 909 return '|'.join([ '%s&%s' % (version, tag) for tag in tags]) |
| 881 | 910 |
| 882 | 911 |
| 883 class DromaeoFileProcessor(Processor): | 912 class DromaeoFileProcessor(Processor): |
| 884 def process_file(self, afile): | 913 def process_file(self, afile): |
| 885 """Comb through the html to find the performance results.""" | 914 """Comb through the html to find the performance results.""" |
| 886 parts = afile.split('-') | 915 parts = afile.split('-') |
| 887 browser = parts[2] | 916 browser = parts[2] |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 while True: | 1248 while True: |
| 1220 if runner.has_new_code(): | 1249 if runner.has_new_code(): |
| 1221 runner.run_test_sequence() | 1250 runner.run_test_sequence() |
| 1222 else: | 1251 else: |
| 1223 time.sleep(200) | 1252 time.sleep(200) |
| 1224 else: | 1253 else: |
| 1225 runner.run_test_sequence() | 1254 runner.run_test_sequence() |
| 1226 | 1255 |
| 1227 if __name__ == '__main__': | 1256 if __name__ == '__main__': |
| 1228 main() | 1257 main() |
| OLD | NEW |