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 math | 8 import math |
| 9 try: | 9 try: |
| 10 from matplotlib.font_manager import FontProperties | 10 from matplotlib.font_manager import FontProperties |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 class CommonBrowserFileProcessor(Processor): | 684 class CommonBrowserFileProcessor(Processor): |
| 685 def process_file(self, afile, should_post_file): | 685 def process_file(self, afile, should_post_file): |
| 686 """Comb through the html to find the performance results. | 686 """Comb through the html to find the performance results. |
| 687 Returns: True if we successfully posted our data to storage and/or we can | 687 Returns: True if we successfully posted our data to storage and/or we can |
| 688 delete the trace file.""" | 688 delete the trace file.""" |
| 689 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', | 689 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', |
| 690 'testing', 'perf_testing')) | 690 'testing', 'perf_testing')) |
| 691 parts = afile.split('-') | 691 parts = afile.split('-') |
| 692 browser = parts[2] | 692 browser = parts[2] |
| 693 version = parts[3] | 693 version = parts[3] |
| 694 if should_post_file: | 694 file_path = os.path.join(self.test.result_folder_name, afile) |
|
vsm
2012/05/09 20:53:11
Consider refactoring into Processor base class.
Emily Fortuna
2012/05/09 20:57:07
Will do!
| |
| 695 f = open(os.path.join(self.test.result_folder_name, afile)) | 695 if not should_post_file: |
| 696 else: | 696 file_path = os.path.join('old', file_path) |
| 697 f = open(os.path.join('old', self.test.result_folder_name, afile)) | 697 f = open(file_path) |
| 698 lines = f.readlines() | 698 lines = f.readlines() |
| 699 line = '' | 699 line = '' |
| 700 i = 0 | 700 i = 0 |
| 701 revision_num = 0 | 701 revision_num = 0 |
| 702 while '<div id="results">' not in line and i < len(lines): | 702 while '<div id="results">' not in line and i < len(lines): |
| 703 if 'Revision' in line: | 703 if 'Revision' in line: |
| 704 revision_num = int(line.split()[1].strip('"')) | 704 revision_num = int(line.split()[1].strip('"')) |
| 705 line = lines[i] | 705 line = lines[i] |
| 706 i += 1 | 706 i += 1 |
| 707 | 707 |
| 708 if i >= len(lines) or revision_num == 0: | 708 if i >= len(lines) or revision_num == 0: |
| 709 # Then this run did not complete. Ignore this tracefile. | 709 # Then this run did not complete. Ignore this tracefile. |
| 710 return True | 710 return True |
| 711 | 711 |
| 712 line = lines[i] | 712 line = lines[i] |
| 713 i += 1 | 713 i += 1 |
| 714 results = [] | 714 results = [] |
| 715 if line.find('<br>') > -1: | 715 if line.find('<br>') > -1: |
| 716 results = line.split('<br>') | 716 results = line.split('<br>') |
| 717 else: | 717 else: |
| 718 results = line.split('<br />') | 718 results = line.split('<br />') |
| 719 if results == []: | 719 if results == []: |
| 720 return True | 720 return True |
| 721 upload_success = True | 721 upload_success = True |
| 722 for result in results: | 722 for result in results: |
| 723 name_and_score = result.split(':') | 723 name_and_score = result.split(':') |
| 724 if len(name_and_score) < 2: | 724 if len(name_and_score) < 2: |
| 725 break | 725 return True |
| 726 name = name_and_score[0].strip() | 726 name = name_and_score[0].strip() |
| 727 score = name_and_score[1].strip() | 727 score = name_and_score[1].strip() |
| 728 if version == 'js' or version == 'v8': | 728 if version == 'js' or version == 'v8': |
| 729 version = 'js' | 729 version = 'js' |
| 730 bench_dict = self.test.values_dict[browser][version] | 730 bench_dict = self.test.values_dict[browser][version] |
| 731 bench_dict[name] += [float(score)] | 731 bench_dict[name] += [float(score)] |
| 732 self.test.revision_dict[browser][version][name] += [revision_num] | 732 self.test.revision_dict[browser][version][name] += [revision_num] |
| 733 if not self.test.test_runner.no_upload and should_post_file: | 733 if not self.test.test_runner.no_upload and should_post_file: |
| 734 upload_success = upload_success and self.report_results( | 734 upload_success = upload_success and self.report_results( |
| 735 name, score, browser, version, revision_num, self.SCORE) | 735 name, score, browser, version, revision_num, self.SCORE) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 875 class DromaeoFileProcessor(Processor): | 875 class DromaeoFileProcessor(Processor): |
| 876 def process_file(self, afile, should_post_file): | 876 def process_file(self, afile, should_post_file): |
| 877 """Comb through the html to find the performance results. | 877 """Comb through the html to find the performance results. |
| 878 Returns: True if we successfully posted our data to storage.""" | 878 Returns: True if we successfully posted our data to storage.""" |
| 879 parts = afile.split('-') | 879 parts = afile.split('-') |
| 880 browser = parts[2] | 880 browser = parts[2] |
| 881 version = parts[3] | 881 version = parts[3] |
| 882 | 882 |
| 883 bench_dict = self.test.values_dict[browser][version] | 883 bench_dict = self.test.values_dict[browser][version] |
| 884 | 884 |
| 885 f = open(os.path.join(self.test.result_folder_name, afile)) | 885 file_path = os.path.join(self.test.result_folder_name, afile) |
| 886 if not should_post_file: | |
| 887 file_path = os.path.join('old', file_path) | |
| 888 f = open(file_path) | |
| 886 lines = f.readlines() | 889 lines = f.readlines() |
| 887 i = 0 | 890 i = 0 |
| 888 revision_num = 0 | 891 revision_num = 0 |
| 889 revision_pattern = r'Revision: (\d+)' | 892 revision_pattern = r'Revision: (\d+)' |
| 890 suite_pattern = r'<div class="result-item done">(.+?)</ol></div>' | 893 suite_pattern = r'<div class="result-item done">(.+?)</ol></div>' |
| 891 result_pattern = r'<b>(.+?)</b>(.+?)<small> runs/s(.+)' | 894 result_pattern = r'<b>(.+?)</b>(.+?)<small> runs/s(.+)' |
| 892 | 895 |
| 893 upload_success = True | 896 upload_success = True |
| 894 for line in lines: | 897 for line in lines: |
| 895 rev = re.match(revision_pattern, line.strip()) | 898 rev = re.match(revision_pattern, line.strip()) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1003 | 1006 |
| 1004 class DromaeoSizeProcessor(Processor): | 1007 class DromaeoSizeProcessor(Processor): |
| 1005 def process_file(self, afile, should_post_file): | 1008 def process_file(self, afile, should_post_file): |
| 1006 """Pull all the relevant information out of a given tracefile. | 1009 """Pull all the relevant information out of a given tracefile. |
| 1007 | 1010 |
| 1008 Args: | 1011 Args: |
| 1009 afile: is the filename string we will be processing. | 1012 afile: is the filename string we will be processing. |
| 1010 Returns: True if we successfully posted our data to storage.""" | 1013 Returns: True if we successfully posted our data to storage.""" |
| 1011 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', | 1014 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', |
| 1012 'testing', 'perf_testing')) | 1015 'testing', 'perf_testing')) |
| 1013 f = open(os.path.join(self.test.result_folder_name, afile)) | 1016 file_path = os.path.join(self.test.result_folder_name, afile) |
| 1017 if not should_post_file: | |
| 1018 file_path = os.path.join('old', file_path) | |
| 1019 f = open(file_path) | |
| 1014 tabulate_data = False | 1020 tabulate_data = False |
| 1015 revision_num = 0 | 1021 revision_num = 0 |
| 1016 revision_pattern = r'Revision: (\d+)' | 1022 revision_pattern = r'Revision: (\d+)' |
| 1017 result_pattern = r'Size \((\w+), ([a-zA-Z0-9-]+)\): (\d+)' | 1023 result_pattern = r'Size \((\w+), ([a-zA-Z0-9-]+)\): (\d+)' |
| 1018 | 1024 |
| 1019 upload_success = True | 1025 upload_success = True |
| 1020 for line in f.readlines(): | 1026 for line in f.readlines(): |
| 1021 rev = re.match(revision_pattern, line.strip()) | 1027 rev = re.match(revision_pattern, line.strip()) |
| 1022 if rev: | 1028 if rev: |
| 1023 revision_num = int(rev.group(1)) | 1029 revision_num = int(rev.group(1)) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1132 class CompileProcessor(Processor): | 1138 class CompileProcessor(Processor): |
| 1133 | 1139 |
| 1134 def process_file(self, afile, should_post_file): | 1140 def process_file(self, afile, should_post_file): |
| 1135 """Pull all the relevant information out of a given tracefile. | 1141 """Pull all the relevant information out of a given tracefile. |
| 1136 | 1142 |
| 1137 Args: | 1143 Args: |
| 1138 afile: is the filename string we will be processing. | 1144 afile: is the filename string we will be processing. |
| 1139 Returns: True if we successfully posted our data to storage.""" | 1145 Returns: True if we successfully posted our data to storage.""" |
| 1140 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', | 1146 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', |
| 1141 'testing', 'perf_testing')) | 1147 'testing', 'perf_testing')) |
| 1142 f = open(os.path.join(self.test.result_folder_name, afile)) | 1148 file_path = os.path.join(self.test.result_folder_name, afile) |
| 1149 if not should_post_file: | |
| 1150 file_path = os.path.join('old', file_path) | |
| 1151 f = open(file_path) | |
| 1143 tabulate_data = False | 1152 tabulate_data = False |
| 1144 revision_num = 0 | 1153 revision_num = 0 |
| 1145 upload_success = True | 1154 upload_success = True |
| 1146 for line in f.readlines(): | 1155 for line in f.readlines(): |
| 1147 tokens = line.split() | 1156 tokens = line.split() |
| 1148 if 'Revision' in line: | 1157 if 'Revision' in line: |
| 1149 revision_num = int(line.split()[1]) | 1158 revision_num = int(line.split()[1]) |
| 1150 else: | 1159 else: |
| 1151 for metric in self.test.values_list: | 1160 for metric in self.test.values_list: |
| 1152 if metric in line: | 1161 if metric in line: |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1164 if not self.test.test_runner.no_upload and should_post_file: | 1173 if not self.test.test_runner.no_upload and should_post_file: |
| 1165 if num < self.test.failure_threshold[metric]: | 1174 if num < self.test.failure_threshold[metric]: |
| 1166 num = 0 | 1175 num = 0 |
| 1167 upload_success = upload_success and self.report_results( | 1176 upload_success = upload_success and self.report_results( |
| 1168 metric, num, 'commandline', 'frog', revision_num, | 1177 metric, num, 'commandline', 'frog', revision_num, |
| 1169 score_type) | 1178 score_type) |
| 1170 else: | 1179 else: |
| 1171 upload_success = False | 1180 upload_success = False |
| 1172 if revision_num != 0: | 1181 if revision_num != 0: |
| 1173 for metric in self.test.values_list: | 1182 for metric in self.test.values_list: |
| 1174 self.test.revision_dict['commandline']['frog'][metric].pop() | 1183 try: |
| 1175 self.test.revision_dict['commandline']['frog'][metric] += \ | 1184 self.test.revision_dict['commandline']['frog'][metric].pop() |
| 1176 [revision_num] | |
| 1177 # Fill in 0 if compilation failed. | |
| 1178 if self.test.values_dict['commandline']['frog'][metric][-1] < \ | |
| 1179 self.test.failure_threshold[metric]: | |
| 1180 self.test.values_dict['commandline']['frog'][metric] += [0] | |
| 1181 self.test.revision_dict['commandline']['frog'][metric] += \ | 1185 self.test.revision_dict['commandline']['frog'][metric] += \ |
| 1182 [revision_num] | 1186 [revision_num] |
| 1187 # Fill in 0 if compilation failed. | |
| 1188 if self.test.values_dict['commandline']['frog'][metric][-1] < \ | |
| 1189 self.test.failure_threshold[metric]: | |
| 1190 self.test.values_dict['commandline']['frog'][metric] += [0] | |
| 1191 self.test.revision_dict['commandline']['frog'][metric] += \ | |
| 1192 [revision_num] | |
| 1193 except IndexError: | |
| 1194 # We tried to pop from an empty list. This happens if the first | |
| 1195 # trace file we encounter is incomplete. | |
| 1196 pass | |
| 1183 | 1197 |
| 1184 f.close() | 1198 f.close() |
| 1185 return upload_success | 1199 return upload_success |
| 1186 | 1200 |
| 1187 class CompileGrapher(Grapher): | 1201 class CompileGrapher(Grapher): |
| 1188 | 1202 |
| 1189 def plot_results(self, png_filename): | 1203 def plot_results(self, png_filename): |
| 1190 self.style_and_save_perf_plot( | 1204 self.style_and_save_perf_plot( |
| 1191 'Compiled frog sizes', 'Size (in bytes)', 10, 10, 'lower left', | 1205 'Compiled frog sizes', 'Size (in bytes)', 10, 10, 'lower left', |
| 1192 png_filename, ['commandline'], ['frog'], ['swarm', 'total']) | 1206 png_filename, ['commandline'], ['frog'], ['swarm', 'total']) |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1213 while True: | 1227 while True: |
| 1214 if runner.has_new_code(): | 1228 if runner.has_new_code(): |
| 1215 runner.run_test_sequence() | 1229 runner.run_test_sequence() |
| 1216 else: | 1230 else: |
| 1217 time.sleep(200) | 1231 time.sleep(200) |
| 1218 else: | 1232 else: |
| 1219 runner.run_test_sequence() | 1233 runner.run_test_sequence() |
| 1220 | 1234 |
| 1221 if __name__ == '__main__': | 1235 if __name__ == '__main__': |
| 1222 main() | 1236 main() |
| OLD | NEW |