Chromium Code Reviews| 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 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 out.seek(0, os.SEEK_END) | 71 out.seek(0, os.SEEK_END) |
| 72 p = subprocess.Popen(cmd_list, stdout = out, stderr=subprocess.PIPE, | 72 p = subprocess.Popen(cmd_list, stdout = out, stderr=subprocess.PIPE, |
| 73 stdin=subprocess.PIPE, shell=self.has_shell) | 73 stdin=subprocess.PIPE, shell=self.has_shell) |
| 74 output, stderr = p.communicate(std_in) | 74 output, stderr = p.communicate(std_in) |
| 75 if output: | 75 if output: |
| 76 print output | 76 print output |
| 77 if stderr: | 77 if stderr: |
| 78 print stderr | 78 print stderr |
| 79 return output, stderr | 79 return output, stderr |
| 80 | 80 |
| 81 def RunBrowserPerfRunnerCmd(self, browser, url_path, file_path_to_test_code, | |
| 82 trace_file, code_root=''): | |
| 83 command_list = [os.path.join(DART_REPO_LOC, utils.GetBuildRoot( | |
| 84 utils.GuessOS(), 'release', 'ia32'), 'dart-sdk', 'bin', 'dart'), | |
| 85 '--package-root=%s' % os.path.join(file_path_to_test_code, 'packages'), | |
| 86 os.path.join(file_path_to_test_code, 'packages', | |
| 87 'browser_controller', 'browser_perf_testing.dart'), '--browser', | |
| 88 browser, '--test_path=%s' % url_path] | |
| 89 if code_root != '': | |
| 90 command_list += ['--code_root=%s' % code_root] | |
| 91 self.RunCmd(command_list, trace_file, append=True) | |
| 92 | |
| 81 def TimeCmd(self, cmd): | 93 def TimeCmd(self, cmd): |
| 82 """Determine the amount of (real) time it takes to execute a given | 94 """Determine the amount of (real) time it takes to execute a given |
| 83 command.""" | 95 command.""" |
| 84 start = time.time() | 96 start = time.time() |
| 85 self.RunCmd(cmd) | 97 self.RunCmd(cmd) |
| 86 return time.time() - start | 98 return time.time() - start |
| 87 | 99 |
| 88 def ClearOutUnversionedFiles(self): | 100 def ClearOutUnversionedFiles(self): |
| 89 """Remove all files that are unversioned by svn.""" | 101 """Remove all files that are unversioned by svn.""" |
| 90 if os.path.exists(DART_REPO_LOC): | 102 if os.path.exists(DART_REPO_LOC): |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 or 'InvalidUriError' in stderr or "Couldn't download" in stdout or | 181 or 'InvalidUriError' in stderr or "Couldn't download" in stdout or |
| 170 'Unable to download' in stdout): | 182 'Unable to download' in stdout): |
| 171 # Couldn't find the SDK on Google Storage. Build it locally. | 183 # Couldn't find the SDK on Google Storage. Build it locally. |
| 172 | 184 |
| 173 # TODO(efortuna): Currently always building ia32 architecture because we | 185 # TODO(efortuna): Currently always building ia32 architecture because we |
| 174 # don't have test statistics for what's passing on x64. Eliminate arch | 186 # don't have test statistics for what's passing on x64. Eliminate arch |
| 175 # specification when we have tests running on x64, too. | 187 # specification when we have tests running on x64, too. |
| 176 shutil.rmtree(os.path.join(os.getcwd(), | 188 shutil.rmtree(os.path.join(os.getcwd(), |
| 177 utils.GetBuildRoot(utils.GuessOS())), | 189 utils.GetBuildRoot(utils.GuessOS())), |
| 178 onerror=TestRunner._OnRmError) | 190 onerror=TestRunner._OnRmError) |
| 179 lines = self.RunCmd([os.path.join('.', 'tools', 'build.py'), '-m', | 191 lines = self.RunCmd(['python', os.path.join('tools', 'build.py'), '-m', |
| 180 'release', '--arch=ia32', 'create_sdk']) | 192 'release', '--arch=ia32', 'create_sdk']) |
| 181 | 193 |
| 182 for line in lines: | 194 for line in lines: |
| 183 if 'BUILD FAILED' in line: | 195 if 'BUILD FAILED' in line: |
| 184 # Someone checked in a broken build! Stop trying to make it work | 196 # Someone checked in a broken build! Stop trying to make it work |
| 185 # and wait to try again. | 197 # and wait to try again. |
| 186 print 'Broken Build' | 198 print 'Broken Build' |
| 187 return 1 | 199 return 1 |
| 188 return 0 | 200 return 0 |
| 189 | 201 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 714 | 726 |
| 715 class DromaeoPerfTester(DromaeoTester): | 727 class DromaeoPerfTester(DromaeoTester): |
| 716 def RunTests(self): | 728 def RunTests(self): |
| 717 """Run dromaeo in the browser.""" | 729 """Run dromaeo in the browser.""" |
| 718 success, _, _ = self.test.test_runner.GetArchive('dartium') | 730 success, _, _ = self.test.test_runner.GetArchive('dartium') |
| 719 if not success: | 731 if not success: |
| 720 # Unable to download dartium. Try later. | 732 # Unable to download dartium. Try later. |
| 721 return | 733 return |
| 722 | 734 |
| 723 # Build tests. | 735 # Build tests. |
| 724 # TODO(efortuna): Make the pub functionality a separate function. | |
| 725 current_path = os.getcwd() | 736 current_path = os.getcwd() |
| 726 os.chdir(os.path.join(DART_REPO_LOC, 'samples', 'third_party', | 737 os.chdir(os.path.join(DART_REPO_LOC, 'samples', 'third_party', |
| 727 'dromaeo')) | 738 'dromaeo')) |
| 728 self.test.test_runner.RunCmd([os.path.join(DART_REPO_LOC, | |
| 729 utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'), | |
| 730 'dart-sdk', 'bin', 'pub'), 'install']) # TODO: pub upgrade? | |
| 731 stdout, _ = self.test.test_runner.RunCmd([os.path.join(DART_REPO_LOC, | 739 stdout, _ = self.test.test_runner.RunCmd([os.path.join(DART_REPO_LOC, |
| 732 utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'), | 740 utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'), |
| 733 'dart-sdk', 'bin', 'pub'), 'build']) | 741 'dart-sdk', 'bin', 'pub'), 'build', '--mode=debug']) |
|
Jennifer Messerly
2014/03/19 19:27:57
should this be debug? Might be worth a comment eit
Emily Fortuna
2014/03/24 19:45:56
Yes, this is debug on purpose. Siggi and I discuss
| |
| 734 os.chdir(current_path) | 742 os.chdir(current_path) |
| 735 if 'failed' in stdout: | 743 if 'failed' in stdout: |
| 736 return | 744 return |
| 737 | 745 |
| 738 versions = DromaeoTester.GetDromaeoVersions() | 746 versions = DromaeoTester.GetDromaeoVersions() |
| 739 | 747 |
| 740 for browser in BrowserTester.GetBrowsers(): | 748 for browser in BrowserTester.GetBrowsers(): |
| 741 for version_name in versions: | 749 for version_name in versions: |
| 742 if not self.test.IsValidCombination(browser, version_name): | 750 if not self.test.IsValidCombination(browser, version_name): |
| 743 continue | 751 continue |
| 744 version = DromaeoTest.DromaeoPerfTester.GetDromaeoUrlQuery( | 752 version = DromaeoTest.DromaeoPerfTester.GetDromaeoUrlQuery( |
| 745 browser, version_name) | 753 browser, version_name) |
| 746 self.test.trace_file = os.path.join(TOP_LEVEL_DIR, | 754 self.test.trace_file = os.path.join(TOP_LEVEL_DIR, |
| 747 'tools', 'testing', 'perf_testing', self.test.result_folder_name, | 755 'tools', 'testing', 'perf_testing', self.test.result_folder_name, |
| 748 'dromaeo-%s-%s-%s' % (self.test.cur_time, browser, version_name)) | 756 'dromaeo-%s-%s-%s' % (self.test.cur_time, browser, version_name)) |
| 749 self.AddSvnRevisionToTrace(self.test.trace_file, browser) | 757 self.AddSvnRevisionToTrace(self.test.trace_file, browser) |
| 750 url_path = '/'.join(['/code_root', 'build', 'web', 'index%s.html?%s'%( | 758 url_path = '/'.join(['/code_root', 'build', 'web', 'index%s.html?%s'%( |
| 751 '-dart' if version_name == 'dart_html' else '-js', | 759 '-dart' if version_name == 'dart_html' else '-js', |
| 752 version)]) | 760 version)]) |
| 753 | 761 |
| 754 self.test.test_runner.RunCmd( | 762 self.test.test_runner.RunBrowserPerfRunnerCmd(browser, url_path, |
| 755 [os.path.join(DART_REPO_LOC, utils.GetBuildRoot( | 763 os.path.join(DART_REPO_LOC, 'samples', 'third_party', 'dromaeo'), |
| 756 utils.GuessOS(), 'release', 'ia32'), 'dart-sdk', 'bin', 'dart'), | 764 self.test.trace_file) |
| 757 '--package-root=%s' % os.path.join(DART_REPO_LOC, 'samples', | |
| 758 'third_party', 'dromaeo', 'packages'), os.path.join( | |
| 759 DART_REPO_LOC, 'samples', 'third_party', 'dromaeo', 'packages', | |
| 760 'browser_controller', 'browser_perf_testing.dart'), | |
| 761 '--browser', browser, | |
| 762 '--test_path', url_path], self.test.trace_file, | |
| 763 append=True) | |
| 764 | 765 |
| 765 @staticmethod | 766 @staticmethod |
| 766 def GetDromaeoUrlQuery(browser, version): | 767 def GetDromaeoUrlQuery(browser, version): |
| 767 version = version.replace('_','AND') | 768 version = version.replace('_','AND') |
| 768 tags = DromaeoTester.GetValidDromaeoTags() | 769 tags = DromaeoTester.GetValidDromaeoTags() |
| 769 return 'OR'.join([ '%sAND%s' % (version, tag) for tag in tags]) | 770 return 'OR'.join([ '%sAND%s' % (version, tag) for tag in tags]) |
| 770 | 771 |
| 771 | 772 |
| 772 class DromaeoFileProcessor(Processor): | 773 class DromaeoFileProcessor(Processor): |
| 773 def ProcessFile(self, afile, should_post_file): | 774 def ProcessFile(self, afile, should_post_file): |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 upload_success = upload_success and self.ReportResults( | 811 upload_success = upload_success and self.ReportResults( |
| 811 name, score, browser, version, revision_num, | 812 name, score, browser, version, revision_num, |
| 812 self.GetScoreType(name)) | 813 self.GetScoreType(name)) |
| 813 else: | 814 else: |
| 814 upload_success = False | 815 upload_success = False |
| 815 | 816 |
| 816 f.close() | 817 f.close() |
| 817 self.CalculateGeometricMean(browser, version, revision_num) | 818 self.CalculateGeometricMean(browser, version, revision_num) |
| 818 return upload_success | 819 return upload_success |
| 819 | 820 |
| 821 class TodoMVCTester(BrowserTester): | |
| 822 @staticmethod | |
| 823 def GetVersions(): | |
| 824 return ['js', 'dart2js_html', 'dart_html'] | |
| 825 | |
| 826 @staticmethod | |
| 827 def GetBenchmarks(): | |
| 828 return ['TodoMVCstartup'] | |
| 829 | |
| 830 class TodoMVCStartupTest(RuntimePerformanceTest): | |
| 831 """Start up TodoMVC and see how long it takes to start.""" | |
| 832 def __init__(self, test_runner): | |
| 833 super(TodoMVCStartupTest, self).__init__( | |
| 834 self.Name(), | |
| 835 BrowserTester.GetBrowsers(True), | |
| 836 'browser', | |
| 837 TodoMVCTester.GetVersions(), | |
| 838 TodoMVCTester.GetBenchmarks(), test_runner, | |
| 839 self.TodoMVCStartupTester(self), | |
| 840 self.TodoMVCFileProcessor(self)) | |
| 841 | |
| 842 @staticmethod | |
| 843 def Name(): | |
| 844 return 'todoMvcStartup' | |
| 845 | |
| 846 class TodoMVCStartupTester(BrowserTester): | |
| 847 def RunTests(self): | |
| 848 """Run dromaeo in the browser.""" | |
| 849 success, _, _ = self.test.test_runner.GetArchive('dartium') | |
| 850 if not success: | |
| 851 # Unable to download dartium. Try later. | |
| 852 return | |
| 853 | |
| 854 dromaeo_path = os.path.join('samples', 'third_party', 'dromaeo') | |
|
Jennifer Messerly
2014/03/19 19:27:57
future TODO: maybe we should move both of these ou
Emily Fortuna
2014/03/24 19:45:56
I'm going to leave this as is for now because of t
| |
| 855 current_path = os.getcwd() | |
| 856 | |
| 857 os.chdir(os.path.join(DART_REPO_LOC, 'samples', 'third_party', | |
| 858 'todomvc_performance')) | |
|
Jennifer Messerly
2014/03/19 19:27:57
fyi -- I was thinking of moving TodoMVC out of thi
| |
| 859 self.test.test_runner.RunCmd([os.path.join(DART_REPO_LOC, | |
| 860 utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'), | |
| 861 'dart-sdk', 'bin', 'pub'), 'build', '--mode=debug']) | |
| 862 os.chdir('js_todomvc'); | |
| 863 self.test.test_runner.RunCmd([os.path.join(DART_REPO_LOC, | |
| 864 utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'), | |
| 865 'dart-sdk', 'bin', 'pub'), 'get']) | |
| 866 | |
| 867 versions = TodoMVCTester.GetVersions() | |
| 868 | |
| 869 for browser in BrowserTester.GetBrowsers(): | |
| 870 for version_name in versions: | |
| 871 if not self.test.IsValidCombination(browser, version_name): | |
| 872 continue | |
| 873 self.test.trace_file = os.path.join(TOP_LEVEL_DIR, | |
| 874 'tools', 'testing', 'perf_testing', self.test.result_folder_name, | |
| 875 'todoMvcStartup-%s-%s-%s' % (self.test.cur_time, browser, | |
| 876 version_name)) | |
| 877 self.AddSvnRevisionToTrace(self.test.trace_file, browser) | |
| 878 | |
| 879 if version_name == 'js': | |
| 880 code_root = os.path.join(DART_REPO_LOC, 'samples', 'third_party', | |
| 881 'todomvc_performance', 'js_todomvc') | |
| 882 self.test.test_runner.RunBrowserPerfRunnerCmd(browser, | |
| 883 '/code_root/index.html', code_root, self.test.trace_file, | |
| 884 code_root) | |
| 885 else: | |
| 886 self.test.test_runner.RunBrowserPerfRunnerCmd(browser, | |
| 887 '/code_root/build/web/startup-performance.html', os.path.join( | |
| 888 DART_REPO_LOC, 'samples', 'third_party', 'todomvc_performance'), | |
| 889 self.test.trace_file) | |
| 890 | |
| 891 class TodoMVCFileProcessor(Processor): | |
| 892 def ProcessFile(self, afile, should_post_file): | |
| 893 """Comb through the html to find the performance results. | |
| 894 Returns: True if we successfully posted our data to storage.""" | |
| 895 parts = afile.split('-') | |
| 896 browser = parts[2] | |
| 897 version = parts[3] | |
| 898 | |
| 899 bench_dict = self.test.values_dict[browser][version] | |
| 900 | |
| 901 f = self.OpenTraceFile(afile, should_post_file) | |
| 902 lines = f.readlines() | |
| 903 i = 0 | |
| 904 revision_num = 0 | |
| 905 revision_pattern = r'Revision: (\d+)' | |
| 906 result_pattern = r'The startup time is (\d+)' | |
| 907 | |
| 908 upload_success = True | |
| 909 for line in lines: | |
| 910 rev = re.match(revision_pattern, line.strip().replace('"', '')) | |
| 911 if rev: | |
| 912 revision_num = int(rev.group(1)) | |
| 913 continue | |
| 914 | |
| 915 results = re.search(result_pattern, line) | |
| 916 if results: | |
| 917 score = float(results.group(1)) | |
| 918 name = TodoMVCTester.GetBenchmarks()[0] | |
| 919 bench_dict[name] += [float(score)] | |
| 920 self.test.revision_dict[browser][version][name] += \ | |
| 921 [revision_num] | |
| 922 if not self.test.test_runner.no_upload and should_post_file: | |
| 923 upload_success = upload_success and self.ReportResults( | |
| 924 name, score, browser, version, revision_num, | |
| 925 self.GetScoreType(name)) | |
| 926 | |
| 927 f.close() | |
| 928 self.CalculateGeometricMean(browser, version, revision_num) | |
| 929 return upload_success | |
| 930 | |
| 931 | |
| 820 class TestBuilder(object): | 932 class TestBuilder(object): |
| 821 """Construct the desired test object.""" | 933 """Construct the desired test object.""" |
| 822 available_suites = dict((suite.Name(), suite) for suite in [ | 934 available_suites = dict((suite.Name(), suite) for suite in [ |
| 823 DromaeoTest]) | 935 DromaeoTest, TodoMVCStartupTest]) |
| 824 | 936 |
| 825 @staticmethod | 937 @staticmethod |
| 826 def MakeTest(test_name, test_runner): | 938 def MakeTest(test_name, test_runner): |
| 827 return TestBuilder.available_suites[test_name](test_runner) | 939 return TestBuilder.available_suites[test_name](test_runner) |
| 828 | 940 |
| 829 @staticmethod | 941 @staticmethod |
| 830 def AvailableSuiteNames(): | 942 def AvailableSuiteNames(): |
| 831 return TestBuilder.available_suites.keys() | 943 return TestBuilder.available_suites.keys() |
| 832 | 944 |
| 833 | 945 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 949 else: | 1061 else: |
| 950 if runner.backfill: | 1062 if runner.backfill: |
| 951 results_set = FillInBackHistory(results_set, runner) | 1063 results_set = FillInBackHistory(results_set, runner) |
| 952 else: | 1064 else: |
| 953 time.sleep(200) | 1065 time.sleep(200) |
| 954 else: | 1066 else: |
| 955 runner.RunTestSequence() | 1067 runner.RunTestSequence() |
| 956 | 1068 |
| 957 if __name__ == '__main__': | 1069 if __name__ == '__main__': |
| 958 main() | 1070 main() |
| OLD | NEW |