| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, 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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 tester: The visitor that actually performs the test running mechanics. | 571 tester: The visitor that actually performs the test running mechanics. |
| 572 file_processor: The visitor that processes files in the format | 572 file_processor: The visitor that processes files in the format |
| 573 appropriate for this test. | 573 appropriate for this test. |
| 574 grapher: The visitor that generates graphs given our test result data. | 574 grapher: The visitor that generates graphs given our test result data. |
| 575 extra_metrics: A list of any additional measurements we wish to keep | 575 extra_metrics: A list of any additional measurements we wish to keep |
| 576 track of (such as the geometric mean of a set, the sum, etc). | 576 track of (such as the geometric mean of a set, the sum, etc). |
| 577 build_targets: The targets necessary to build to run these tests | 577 build_targets: The targets necessary to build to run these tests |
| 578 (default target is create_sdk).""" | 578 (default target is create_sdk).""" |
| 579 super(RuntimePerformanceTest, self).__init__(result_folder_name, | 579 super(RuntimePerformanceTest, self).__init__(result_folder_name, |
| 580 platform_list, versions, benchmarks, test_runner, tester, | 580 platform_list, versions, benchmarks, test_runner, tester, |
| 581 file_processor, self.RuntimePerfGrapher(self), | 581 file_processor, RuntimePerfGrapher(self), |
| 582 build_targets=build_targets) | 582 build_targets=build_targets) |
| 583 self.platform_list = platform_list | 583 self.platform_list = platform_list |
| 584 self.platform_type = platform_type | 584 self.platform_type = platform_type |
| 585 self.versions = versions | 585 self.versions = versions |
| 586 self.benchmarks = benchmarks | 586 self.benchmarks = benchmarks |
| 587 | 587 |
| 588 class RuntimePerfGrapher(Grapher): | 588 class RuntimePerfGrapher(Grapher): |
| 589 def plot_all_perf(self, png_filename): | 589 def plot_all_perf(self, png_filename): |
| 590 """Create a plot that shows the performance changes of individual | 590 """Create a plot that shows the performance changes of individual |
| 591 benchmarks run by JS and generated by frog, over svn history.""" | 591 benchmarks run by JS and generated by frog, over svn history.""" |
| 592 for benchmark in self.test.benchmarks: | 592 for benchmark in self.test.benchmarks: |
| 593 self.style_and_save_perf_plot( | 593 self.style_and_save_perf_plot( |
| 594 'Performance of %s over time on the %s on %s' % (benchmark, | 594 'Performance of %s over time on the %s on %s' % (benchmark, |
| 595 self.test.platform_type, utils.GuessOS()), | 595 self.test.platform_type, utils.GuessOS()), |
| 596 'Speed (bigger = better)', 16, 14, 'lower left', | 596 'Speed (bigger = better)', 16, 14, 'lower left', |
| 597 benchmark + png_filename, self.test.platform_list, | 597 benchmark + png_filename, self.test.platform_list, |
| 598 self.test.versions, [benchmark]) | 598 self.test.versions, [benchmark]) |
| 599 | 599 |
| 600 def plot_avg_perf(self, png_filename): | 600 def plot_avg_perf(self, png_filename, platforms=None, versions=None): |
| 601 """Generate a plot that shows the performance changes of the geomentric | 601 """Generate a plot that shows the performance changes of the geomentric |
| 602 mean of JS and frog benchmark performance over svn history.""" | 602 mean of JS and frog benchmark performance over svn history.""" |
| 603 (title, y_axis, size_x, size_y, loc, filename) = \ | 603 if platforms == None: |
| 604 ('Geometric Mean of benchmark %s performance on %s ' % | 604 platforms = self.test.platform_list |
| 605 (self.test.platform_type, utils.GuessOS()), 'Speed (bigger = better)', | 605 if versions == None: |
| 606 16, 5, 'lower left', 'avg'+png_filename) | 606 versions = self.test.versions |
| 607 clear_axis = True | 607 (title, y_axis, size_x, size_y, loc, filename) = \ |
| 608 for platform in self.test.platform_list: | 608 ('Geometric Mean of benchmark %s performance on %s ' % |
| 609 for version in self.test.versions: | 609 (self.test.platform_type, utils.GuessOS()), 'Speed (bigger = better)', |
| 610 if self.test.is_valid_combination(platform, version): | 610 16, 5, 'lower left', 'avg'+png_filename) |
| 611 for metric in self.test.extra_metrics: | 611 clear_axis = True |
| 612 self.style_and_save_perf_plot(title, y_axis, size_x, size_y, loc, | 612 for platform in platforms: |
| 613 filename, [platform], [version], | 613 for version in versions: |
| 614 [metric], clear_axis) | 614 if self.test.is_valid_combination(platform, version): |
| 615 clear_axis = False | 615 for metric in self.test.extra_metrics: |
| 616 self.style_and_save_perf_plot(title, y_axis, size_x, size_y, loc, |
| 617 filename, [platform], [version], |
| 618 [metric], clear_axis) |
| 619 clear_axis = False |
| 616 | 620 |
| 617 def plot_results(self, png_filename): | 621 def plot_results(self, png_filename): |
| 618 self.plot_all_perf(png_filename) | 622 self.plot_all_perf(png_filename) |
| 619 self.plot_avg_perf('2' + png_filename) | 623 self.plot_avg_perf('2' + png_filename) |
| 620 | |
| 621 | 624 |
| 622 class BrowserTester(Tester): | 625 class BrowserTester(Tester): |
| 623 @staticmethod | 626 @staticmethod |
| 624 def get_browsers(add_dartium=True): | 627 def get_browsers(add_dartium=True): |
| 625 browsers = ['ff', 'chrome'] | 628 browsers = ['ff', 'chrome'] |
| 626 if add_dartium: | 629 if add_dartium: |
| 627 browsers += ['dartium'] | 630 browsers += ['dartium'] |
| 628 has_shell = False | 631 has_shell = False |
| 629 if platform.system() == 'Darwin': | 632 if platform.system() == 'Darwin': |
| 630 browsers += ['safari'] | 633 browsers += ['safari'] |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 def get_dromaeo_benchmarks(): | 813 def get_dromaeo_benchmarks(): |
| 811 valid = DromaeoTester.get_valid_dromaeo_tags() | 814 valid = DromaeoTester.get_valid_dromaeo_tags() |
| 812 benchmarks = reduce(lambda l1,l2: l1+l2, | 815 benchmarks = reduce(lambda l1,l2: l1+l2, |
| 813 [tests for (tag, tests) in | 816 [tests for (tag, tests) in |
| 814 DromaeoTester.DROMAEO_BENCHMARKS.values() | 817 DromaeoTester.DROMAEO_BENCHMARKS.values() |
| 815 if tag in valid]) | 818 if tag in valid]) |
| 816 return map(DromaeoTester.legalize_filename, benchmarks) | 819 return map(DromaeoTester.legalize_filename, benchmarks) |
| 817 | 820 |
| 818 @staticmethod | 821 @staticmethod |
| 819 def get_dromaeo_versions(): | 822 def get_dromaeo_versions(): |
| 820 return ['js', 'frog_dom', 'frog_html'] | 823 return ['js', 'frog_dom', 'frog_html', 'dart2js_dom', 'dart2js_html'] |
| 821 | 824 |
| 822 | 825 |
| 823 class DromaeoTest(RuntimePerformanceTest): | 826 class DromaeoTest(RuntimePerformanceTest): |
| 824 """Runs Dromaeo tests, in the browser.""" | 827 """Runs Dromaeo tests, in the browser.""" |
| 825 def __init__(self, test_runner): | 828 def __init__(self, test_runner): |
| 826 super(DromaeoTest, self).__init__( | 829 super(DromaeoTest, self).__init__( |
| 827 self.name(), BrowserTester.get_browsers(), 'browser', | 830 self.name(), BrowserTester.get_browsers(), 'browser', |
| 828 DromaeoTester.get_dromaeo_versions(), | 831 DromaeoTester.get_dromaeo_versions(), |
| 829 DromaeoTester.get_dromaeo_benchmarks(), test_runner, | 832 DromaeoTester.get_dromaeo_benchmarks(), test_runner, |
| 830 self.DromaeoPerfTester(self), | 833 self.DromaeoPerfTester(self), |
| 831 self.DromaeoFileProcessor(self)) | 834 self.DromaeoFileProcessor(self)) |
| 835 # TODO(vsm): These tester/grapher/processor classes should be |
| 836 # cleaner to override. |
| 837 self.grapher = self.DromaeoPerfGrapher(self) |
| 832 | 838 |
| 833 @staticmethod | 839 @staticmethod |
| 834 def name(): | 840 def name(): |
| 835 return 'dromaeo' | 841 return 'dromaeo' |
| 836 | 842 |
| 837 def is_valid_combination(self, browser, version): | 843 def is_valid_combination(self, browser, version): |
| 838 # TODO(vsm): This avoids a bug in 32-bit Chrome (dartium) | 844 # TODO(vsm): This avoids a bug in 32-bit Chrome (dartium) |
| 839 # running JS dromaeo. | 845 # running JS dromaeo. |
| 840 if browser == 'dartium' and version == 'js': | 846 if browser == 'dartium' and version == 'js': |
| 841 return False | 847 return False |
| 848 # Only run dart2js on Chrome until we validate it elsewhere. |
| 849 if browser != 'chrome' and 'dart2js' in version: |
| 850 return False |
| 842 return True | 851 return True |
| 843 | 852 |
| 853 class DromaeoPerfGrapher(RuntimePerfGrapher): |
| 854 def plot_results(self, png_filename): |
| 855 self.plot_all_perf(png_filename) |
| 856 self.plot_avg_perf('2' + png_filename) |
| 857 self.plot_avg_perf('3' + png_filename, ['chrome', 'dartium'], |
| 858 ['js', 'frog_dom', 'frog_html']) |
| 859 self.plot_avg_perf('4' + png_filename, ['chrome'], |
| 860 ['js', 'frog_dom', 'dart2js_dom']) |
| 861 self.plot_avg_perf('5' + png_filename, ['chrome'], |
| 862 ['js', 'dart2js_dom', 'dart2js_html']) |
| 863 self.plot_avg_perf('6' + png_filename, ['chrome'], |
| 864 ['js', 'frog_dom', 'frog_html', 'dart2js_dom', |
| 865 'dart2js_html']) |
| 866 |
| 844 class DromaeoPerfTester(DromaeoTester): | 867 class DromaeoPerfTester(DromaeoTester): |
| 845 def move_chrome_driver_if_needed(self, browser): | 868 def move_chrome_driver_if_needed(self, browser): |
| 846 """Move the appropriate version of ChromeDriver onto the path. | 869 """Move the appropriate version of ChromeDriver onto the path. |
| 847 TODO(efortuna): This is a total hack because the latest version of Chrome | 870 TODO(efortuna): This is a total hack because the latest version of Chrome |
| 848 (Dartium builds) requires a different version of ChromeDriver, that is | 871 (Dartium builds) requires a different version of ChromeDriver, that is |
| 849 incompatible with the release or beta Chrome and vice versa. Remove these | 872 incompatible with the release or beta Chrome and vice versa. Remove these |
| 850 shenanigans once we're back to both versions of Chrome using the same | 873 shenanigans once we're back to both versions of Chrome using the same |
| 851 version of ChromeDriver. IMPORTANT NOTE: This assumes your chromedriver is | 874 version of ChromeDriver. IMPORTANT NOTE: This assumes your chromedriver is |
| 852 in the default location (inside depot_tools). | 875 in the default location (inside depot_tools). |
| 853 """ | 876 """ |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 while True: | 1308 while True: |
| 1286 if runner.has_new_code(): | 1309 if runner.has_new_code(): |
| 1287 runner.run_test_sequence() | 1310 runner.run_test_sequence() |
| 1288 else: | 1311 else: |
| 1289 time.sleep(200) | 1312 time.sleep(200) |
| 1290 else: | 1313 else: |
| 1291 runner.run_test_sequence() | 1314 runner.run_test_sequence() |
| 1292 | 1315 |
| 1293 if __name__ == '__main__': | 1316 if __name__ == '__main__': |
| 1294 main() | 1317 main() |
| OLD | NEW |