| 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) 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 |
| 11 import matplotlib.pyplot as plt | 11 import matplotlib.pyplot as plt |
| 12 except ImportError: | 12 except ImportError: |
| 13 pass # Only needed if we want to make graphs. | 13 pass # Only needed if we want to make graphs. |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 COMPILE_TIME = 'CompileTime' | 420 COMPILE_TIME = 'CompileTime' |
| 421 CODE_SIZE = 'CodeSize' | 421 CODE_SIZE = 'CodeSize' |
| 422 | 422 |
| 423 def __init__(self, test): | 423 def __init__(self, test): |
| 424 self.test = test | 424 self.test = test |
| 425 | 425 |
| 426 def prepare(self): | 426 def prepare(self): |
| 427 """Perform any initial setup required before the test is run.""" | 427 """Perform any initial setup required before the test is run.""" |
| 428 pass | 428 pass |
| 429 | 429 |
| 430 def open_trace_file(self, afile, not_yet_uploaded): |
| 431 """Find the correct location for the trace file, and open it. |
| 432 Args: |
| 433 afile: The tracefile name. |
| 434 not_yet_uploaded: True if this file is to be found in a directory that |
| 435 contains un-uploaded data. |
| 436 Returns: A file object corresponding to the given file name.""" |
| 437 file_path = os.path.join(self.test.result_folder_name, afile) |
| 438 if not not_yet_uploaded: |
| 439 file_path = os.path.join('old', file_path) |
| 440 return open(file_path) |
| 441 |
| 430 def report_results(self, benchmark_name, score, platform, variant, | 442 def report_results(self, benchmark_name, score, platform, variant, |
| 431 revision_number, metric): | 443 revision_number, metric): |
| 432 """Store the results of the benchmark run. | 444 """Store the results of the benchmark run. |
| 433 Args: | 445 Args: |
| 434 benchmark_name: The name of the individual benchmark. | 446 benchmark_name: The name of the individual benchmark. |
| 435 score: The numerical value of this benchmark. | 447 score: The numerical value of this benchmark. |
| 436 platform: The platform the test was run on (firefox, command line, etc). | 448 platform: The platform the test was run on (firefox, command line, etc). |
| 437 variant: Specifies whether the data was about generated Frog, js, a | 449 variant: Specifies whether the data was about generated Frog, js, a |
| 438 combination of both, or Dart depending on the test. | 450 combination of both, or Dart depending on the test. |
| 439 revision_number: The revision of the code (and sometimes the revision of | 451 revision_number: The revision of the code (and sometimes the revision of |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 class CommonBrowserFileProcessor(Processor): | 696 class CommonBrowserFileProcessor(Processor): |
| 685 def process_file(self, afile, should_post_file): | 697 def process_file(self, afile, should_post_file): |
| 686 """Comb through the html to find the performance results. | 698 """Comb through the html to find the performance results. |
| 687 Returns: True if we successfully posted our data to storage and/or we can | 699 Returns: True if we successfully posted our data to storage and/or we can |
| 688 delete the trace file.""" | 700 delete the trace file.""" |
| 689 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', | 701 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', |
| 690 'testing', 'perf_testing')) | 702 'testing', 'perf_testing')) |
| 691 parts = afile.split('-') | 703 parts = afile.split('-') |
| 692 browser = parts[2] | 704 browser = parts[2] |
| 693 version = parts[3] | 705 version = parts[3] |
| 694 if should_post_file: | 706 f = self.open_trace_file(afile, should_post_file) |
| 695 f = open(os.path.join(self.test.result_folder_name, afile)) | |
| 696 else: | |
| 697 f = open(os.path.join('old', self.test.result_folder_name, afile)) | |
| 698 lines = f.readlines() | 707 lines = f.readlines() |
| 699 line = '' | 708 line = '' |
| 700 i = 0 | 709 i = 0 |
| 701 revision_num = 0 | 710 revision_num = 0 |
| 702 while '<div id="results">' not in line and i < len(lines): | 711 while '<div id="results">' not in line and i < len(lines): |
| 703 if 'Revision' in line: | 712 if 'Revision' in line: |
| 704 revision_num = int(line.split()[1].strip('"')) | 713 revision_num = int(line.split()[1].strip('"')) |
| 705 line = lines[i] | 714 line = lines[i] |
| 706 i += 1 | 715 i += 1 |
| 707 | 716 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 class DromaeoFileProcessor(Processor): | 884 class DromaeoFileProcessor(Processor): |
| 876 def process_file(self, afile, should_post_file): | 885 def process_file(self, afile, should_post_file): |
| 877 """Comb through the html to find the performance results. | 886 """Comb through the html to find the performance results. |
| 878 Returns: True if we successfully posted our data to storage.""" | 887 Returns: True if we successfully posted our data to storage.""" |
| 879 parts = afile.split('-') | 888 parts = afile.split('-') |
| 880 browser = parts[2] | 889 browser = parts[2] |
| 881 version = parts[3] | 890 version = parts[3] |
| 882 | 891 |
| 883 bench_dict = self.test.values_dict[browser][version] | 892 bench_dict = self.test.values_dict[browser][version] |
| 884 | 893 |
| 885 f = open(os.path.join(self.test.result_folder_name, afile)) | 894 f = self.open_trace_file(afile, should_post_file) |
| 886 lines = f.readlines() | 895 lines = f.readlines() |
| 887 i = 0 | 896 i = 0 |
| 888 revision_num = 0 | 897 revision_num = 0 |
| 889 revision_pattern = r'Revision: (\d+)' | 898 revision_pattern = r'Revision: (\d+)' |
| 890 suite_pattern = r'<div class="result-item done">(.+?)</ol></div>' | 899 suite_pattern = r'<div class="result-item done">(.+?)</ol></div>' |
| 891 result_pattern = r'<b>(.+?)</b>(.+?)<small> runs/s(.+)' | 900 result_pattern = r'<b>(.+?)</b>(.+?)<small> runs/s(.+)' |
| 892 | 901 |
| 893 upload_success = True | 902 upload_success = True |
| 894 for line in lines: | 903 for line in lines: |
| 895 rev = re.match(revision_pattern, line.strip()) | 904 rev = re.match(revision_pattern, line.strip()) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 | 1012 |
| 1004 class DromaeoSizeProcessor(Processor): | 1013 class DromaeoSizeProcessor(Processor): |
| 1005 def process_file(self, afile, should_post_file): | 1014 def process_file(self, afile, should_post_file): |
| 1006 """Pull all the relevant information out of a given tracefile. | 1015 """Pull all the relevant information out of a given tracefile. |
| 1007 | 1016 |
| 1008 Args: | 1017 Args: |
| 1009 afile: is the filename string we will be processing. | 1018 afile: is the filename string we will be processing. |
| 1010 Returns: True if we successfully posted our data to storage.""" | 1019 Returns: True if we successfully posted our data to storage.""" |
| 1011 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', | 1020 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', |
| 1012 'testing', 'perf_testing')) | 1021 'testing', 'perf_testing')) |
| 1013 f = open(os.path.join(self.test.result_folder_name, afile)) | 1022 f = self.open_trace_file(afile, should_post_file) |
| 1014 tabulate_data = False | 1023 tabulate_data = False |
| 1015 revision_num = 0 | 1024 revision_num = 0 |
| 1016 revision_pattern = r'Revision: (\d+)' | 1025 revision_pattern = r'Revision: (\d+)' |
| 1017 result_pattern = r'Size \((\w+), ([a-zA-Z0-9-]+)\): (\d+)' | 1026 result_pattern = r'Size \((\w+), ([a-zA-Z0-9-]+)\): (\d+)' |
| 1018 | 1027 |
| 1019 upload_success = True | 1028 upload_success = True |
| 1020 for line in f.readlines(): | 1029 for line in f.readlines(): |
| 1021 rev = re.match(revision_pattern, line.strip()) | 1030 rev = re.match(revision_pattern, line.strip()) |
| 1022 if rev: | 1031 if rev: |
| 1023 revision_num = int(rev.group(1)) | 1032 revision_num = int(rev.group(1)) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 class CompileProcessor(Processor): | 1141 class CompileProcessor(Processor): |
| 1133 | 1142 |
| 1134 def process_file(self, afile, should_post_file): | 1143 def process_file(self, afile, should_post_file): |
| 1135 """Pull all the relevant information out of a given tracefile. | 1144 """Pull all the relevant information out of a given tracefile. |
| 1136 | 1145 |
| 1137 Args: | 1146 Args: |
| 1138 afile: is the filename string we will be processing. | 1147 afile: is the filename string we will be processing. |
| 1139 Returns: True if we successfully posted our data to storage.""" | 1148 Returns: True if we successfully posted our data to storage.""" |
| 1140 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', | 1149 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', |
| 1141 'testing', 'perf_testing')) | 1150 'testing', 'perf_testing')) |
| 1142 f = open(os.path.join(self.test.result_folder_name, afile)) | 1151 f = self.open_trace_file(afile, should_post_file) |
| 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 |