Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: tools/testing/perf_testing/run_perf_tests.py

Issue 10383053: Store files locally in a different location after they've been posted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 def ensure_output_directory(self, dir_name): 141 def ensure_output_directory(self, dir_name):
142 """Test that the listed directory name exists, and if not, create one for 142 """Test that the listed directory name exists, and if not, create one for
143 our output to be placed. 143 our output to be placed.
144 144
145 Args: 145 Args:
146 dir_name: the directory we will create if it does not exist.""" 146 dir_name: the directory we will create if it does not exist."""
147 dir_path = os.path.join(DART_INSTALL_LOCATION, 'tools', 147 dir_path = os.path.join(DART_INSTALL_LOCATION, 'tools',
148 'testing', 'perf_testing', dir_name) 148 'testing', 'perf_testing', dir_name)
149 if not os.path.exists(dir_path): 149 if not os.path.exists(dir_path):
150 os.mkdir(dir_path) 150 os.makedirs(dir_path)
151 print 'Creating output directory ', dir_path 151 print 'Creating output directory ', dir_path
152 152
153 def has_new_code(self): 153 def has_new_code(self):
154 """Tests if there are any newer versions of files on the server.""" 154 """Tests if there are any newer versions of files on the server."""
155 os.chdir(DART_INSTALL_LOCATION) 155 os.chdir(DART_INSTALL_LOCATION)
156 # Pass 'p' in if we have a new certificate for the svn server, we want to 156 # Pass 'p' in if we have a new certificate for the svn server, we want to
157 # (p)ermanently accept it. 157 # (p)ermanently accept it.
158 results = self.run_cmd(['svn', 'st', '-u'], std_in='p') 158 results = self.run_cmd(['svn', 'st', '-u'], std_in='p\r\n')
159 for line in results: 159 for line in results:
160 if '*' in line: 160 if '*' in line:
161 return True 161 return True
162 return False 162 return False
163 163
164 def get_os_directory(self): 164 def get_os_directory(self):
165 """Specifies the name of the directory for the testing build of dart, which 165 """Specifies the name of the directory for the testing build of dart, which
166 has yet a different naming convention from utils.getBuildRoot(...).""" 166 has yet a different naming convention from utils.getBuildRoot(...)."""
167 if platform.system() == 'Windows': 167 if platform.system() == 'Windows':
168 return 'windows' 168 return 'windows'
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 def run(self): 340 def run(self):
341 """Run the benchmarks/tests from the command line and plot the 341 """Run the benchmarks/tests from the command line and plot the
342 results. 342 results.
343 """ 343 """
344 for visitor in [self.tester, self.file_processor, self.grapher]: 344 for visitor in [self.tester, self.file_processor, self.grapher]:
345 visitor.prepare() 345 visitor.prepare()
346 346
347 os.chdir(DART_INSTALL_LOCATION) 347 os.chdir(DART_INSTALL_LOCATION)
348 self.test_runner.ensure_output_directory(self.result_folder_name) 348 self.test_runner.ensure_output_directory(self.result_folder_name)
349 self.test_runner.ensure_output_directory(os.path.join(
350 'old', self.result_folder_name))
349 if not self.test_runner.no_test: 351 if not self.test_runner.no_test:
350 self.tester.run_tests() 352 self.tester.run_tests()
351 353
352 os.chdir(os.path.join('tools', 'testing', 'perf_testing')) 354 os.chdir(os.path.join('tools', 'testing', 'perf_testing'))
353 355
356 for afile in os.listdir(os.path.join('old', self.result_folder_name)):
357 if not afile.startswith('.'):
358 self.file_processor.process_file(afile, False)
359
354 files = os.listdir(self.result_folder_name) 360 files = os.listdir(self.result_folder_name)
355 for afile in files: 361 for afile in files:
356 if not afile.startswith('.'): 362 if not afile.startswith('.'):
357 self.file_processor.process_file(afile) 363 should_move_file = self.file_processor.process_file(afile, True)
364 if should_move_file:
365 shutil.move(os.path.join(self.result_folder_name, afile),
366 os.path.join('old', self.result_folder_name, afile))
358 367
359 if 'plt' in globals(): 368 if 'plt' in globals():
360 # Only run Matplotlib if it is installed. 369 # Only run Matplotlib if it is installed.
361 self.grapher.plot_results('%s.png' % self.result_folder_name) 370 self.grapher.plot_results('%s.png' % self.result_folder_name)
362 371
363 372
364 class Tester(object): 373 class Tester(object):
365 """The base level visitor class that runs tests. It contains convenience 374 """The base level visitor class that runs tests. It contains convenience
366 methods that many Tester objects use. Any class that would like to be a 375 methods that many Tester objects use. Any class that would like to be a
367 TesterVisitor must implement the run_tests() method.""" 376 TesterVisitor must implement the run_tests() method."""
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 COMPILE_TIME = 'CompileTime' 420 COMPILE_TIME = 'CompileTime'
412 CODE_SIZE = 'CodeSize' 421 CODE_SIZE = 'CodeSize'
413 422
414 def __init__(self, test): 423 def __init__(self, test):
415 self.test = test 424 self.test = test
416 425
417 def prepare(self): 426 def prepare(self):
418 """Perform any initial setup required before the test is run.""" 427 """Perform any initial setup required before the test is run."""
419 pass 428 pass
420 429
421 def should_report_results(self, afile):
422 """We store all trace files locally, but we don't want to post all of the
423 results every time, so we only attempt to post results for recent runs."""
424 cur_time = time.time()
425 file_mod_time = os.path.getmtime(os.path.join(
426 self.test.result_folder_name, afile))
427 return cur_time - file_mod_time < 1000 # Files modified in the last ~15 min.
428
429 def report_results(self, benchmark_name, score, platform, variant, 430 def report_results(self, benchmark_name, score, platform, variant,
430 revision_number, metric): 431 revision_number, metric):
431 """Store the results of the benchmark run. 432 """Store the results of the benchmark run.
432 Args: 433 Args:
433 benchmark_name: The name of the individual benchmark. 434 benchmark_name: The name of the individual benchmark.
434 score: The numerical value of this benchmark. 435 score: The numerical value of this benchmark.
435 platform: The platform the test was run on (firefox, command line, etc). 436 platform: The platform the test was run on (firefox, command line, etc).
436 variant: Specifies whether the data was about generated Frog, js, a 437 variant: Specifies whether the data was about generated Frog, js, a
437 combination of both, or Dart depending on the test. 438 combination of both, or Dart depending on the test.
438 revision_number: The revision of the code (and sometimes the revision of 439 revision_number: The revision of the code (and sometimes the revision of
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 file_path = os.path.join( 675 file_path = os.path.join(
675 os.getcwd(), 'internal', 'browserBenchmarks', 676 os.getcwd(), 'internal', 'browserBenchmarks',
676 'benchmark_page_%s.html' % version) 677 'benchmark_page_%s.html' % version)
677 self.test.test_runner.run_cmd( 678 self.test.test_runner.run_cmd(
678 ['python', os.path.join('tools', 'testing', 'run_selenium.py'), 679 ['python', os.path.join('tools', 'testing', 'run_selenium.py'),
679 '--out', file_path, '--browser', browser, 680 '--out', file_path, '--browser', browser,
680 '--timeout', '600', '--mode', 'perf'], self.test.trace_file, 681 '--timeout', '600', '--mode', 'perf'], self.test.trace_file,
681 append=True) 682 append=True)
682 683
683 class CommonBrowserFileProcessor(Processor): 684 class CommonBrowserFileProcessor(Processor):
684 def process_file(self, afile): 685 def process_file(self, afile, should_post_file):
685 """Comb through the html to find the performance results. 686 """Comb through the html to find the performance results.
686 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
687 delete the trace file.""" 688 delete the trace file."""
688 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', 689 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools',
689 'testing', 'perf_testing')) 690 'testing', 'perf_testing'))
690 parts = afile.split('-') 691 parts = afile.split('-')
691 browser = parts[2] 692 browser = parts[2]
692 version = parts[3] 693 version = parts[3]
693 f = open(os.path.join(self.test.result_folder_name, afile)) 694 if 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))
694 lines = f.readlines() 698 lines = f.readlines()
695 line = '' 699 line = ''
696 i = 0 700 i = 0
697 revision_num = 0 701 revision_num = 0
698 while '<div id="results">' not in line and i < len(lines): 702 while '<div id="results">' not in line and i < len(lines):
699 if 'Revision' in line: 703 if 'Revision' in line:
700 revision_num = int(line.split()[1].strip('"')) 704 revision_num = int(line.split()[1].strip('"'))
701 line = lines[i] 705 line = lines[i]
702 i += 1 706 i += 1
703 707
(...skipping 15 matching lines...) Expand all
719 name_and_score = result.split(':') 723 name_and_score = result.split(':')
720 if len(name_and_score) < 2: 724 if len(name_and_score) < 2:
721 break 725 break
722 name = name_and_score[0].strip() 726 name = name_and_score[0].strip()
723 score = name_and_score[1].strip() 727 score = name_and_score[1].strip()
724 if version == 'js' or version == 'v8': 728 if version == 'js' or version == 'v8':
725 version = 'js' 729 version = 'js'
726 bench_dict = self.test.values_dict[browser][version] 730 bench_dict = self.test.values_dict[browser][version]
727 bench_dict[name] += [float(score)] 731 bench_dict[name] += [float(score)]
728 self.test.revision_dict[browser][version][name] += [revision_num] 732 self.test.revision_dict[browser][version][name] += [revision_num]
729 if self.should_report_results(afile) and \ 733 if not self.test.test_runner.no_upload and should_post_file:
730 not self.test.test_runner.no_upload:
731 upload_success = upload_success and self.report_results( 734 upload_success = upload_success and self.report_results(
732 name, score, browser, version, revision_num, self.SCORE) 735 name, score, browser, version, revision_num, self.SCORE)
733 else: 736 else:
734 upload_success = False 737 upload_success = False
735 738
736 f.close() 739 f.close()
737 self.calculate_geometric_mean(browser, version, revision_num) 740 self.calculate_geometric_mean(browser, version, revision_num)
738 return upload_success 741 return upload_success
739 742
740 743
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 @staticmethod 866 @staticmethod
864 def get_dromaeo_url_query(browser, version): 867 def get_dromaeo_url_query(browser, version):
865 if browser == 'dartium': 868 if browser == 'dartium':
866 version = version.replace('frog', 'dart') 869 version = version.replace('frog', 'dart')
867 version = version.replace('_','&') 870 version = version.replace('_','&')
868 tags = DromaeoTester.get_valid_dromaeo_tags() 871 tags = DromaeoTester.get_valid_dromaeo_tags()
869 return '|'.join([ '%s&%s' % (version, tag) for tag in tags]) 872 return '|'.join([ '%s&%s' % (version, tag) for tag in tags])
870 873
871 874
872 class DromaeoFileProcessor(Processor): 875 class DromaeoFileProcessor(Processor):
873 def process_file(self, afile): 876 def process_file(self, afile, should_post_file):
874 """Comb through the html to find the performance results. 877 """Comb through the html to find the performance results.
875 Returns: True if we successfully posted our data to storage.""" 878 Returns: True if we successfully posted our data to storage."""
876 parts = afile.split('-') 879 parts = afile.split('-')
877 browser = parts[2] 880 browser = parts[2]
878 version = parts[3] 881 version = parts[3]
879 882
880 bench_dict = self.test.values_dict[browser][version] 883 bench_dict = self.test.values_dict[browser][version]
881 884
882 f = open(os.path.join(self.test.result_folder_name, afile)) 885 f = open(os.path.join(self.test.result_folder_name, afile))
883 lines = f.readlines() 886 lines = f.readlines()
(...skipping 15 matching lines...) Expand all
899 for suite_result in suite_results: 902 for suite_result in suite_results:
900 results = re.findall(r'<li>(.*?)</li>', suite_result) 903 results = re.findall(r'<li>(.*?)</li>', suite_result)
901 if results: 904 if results:
902 for result in results: 905 for result in results:
903 r = re.match(result_pattern, result) 906 r = re.match(result_pattern, result)
904 name = DromaeoTester.legalize_filename(r.group(1).strip(':')) 907 name = DromaeoTester.legalize_filename(r.group(1).strip(':'))
905 score = float(r.group(2)) 908 score = float(r.group(2))
906 bench_dict[name] += [float(score)] 909 bench_dict[name] += [float(score)]
907 self.test.revision_dict[browser][version][name] += \ 910 self.test.revision_dict[browser][version][name] += \
908 [revision_num] 911 [revision_num]
909 if self.should_report_results(afile) and \ 912 if not self.test.test_runner.no_upload and should_post_file:
910 not self.test.test_runner.no_upload:
911 upload_success = upload_success and self.report_results( 913 upload_success = upload_success and self.report_results(
912 name, score, browser, version, revision_num, self.SCORE) 914 name, score, browser, version, revision_num, self.SCORE)
913 else: 915 else:
914 upload_success = False 916 upload_success = False
915 917
916 f.close() 918 f.close()
917 self.calculate_geometric_mean(browser, version, revision_num) 919 self.calculate_geometric_mean(browser, version, revision_num)
918 return upload_success 920 return upload_success
919 921
920 922
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 self.test.extra_metrics[0])], 995 self.test.extra_metrics[0])],
994 self.test.trace_file, append=True) 996 self.test.trace_file, append=True)
995 for (variant, _) in variants: 997 for (variant, _) in variants:
996 self.test.test_runner.run_cmd( 998 self.test.test_runner.run_cmd(
997 ['echo', 'Size (%s, %s): %s' % (variant, self.test.extra_metrics[0], 999 ['echo', 'Size (%s, %s): %s' % (variant, self.test.extra_metrics[0],
998 total_size[variant])], 1000 total_size[variant])],
999 self.test.trace_file, append=True) 1001 self.test.trace_file, append=True)
1000 1002
1001 1003
1002 class DromaeoSizeProcessor(Processor): 1004 class DromaeoSizeProcessor(Processor):
1003 def process_file(self, afile): 1005 def process_file(self, afile, should_post_file):
1004 """Pull all the relevant information out of a given tracefile. 1006 """Pull all the relevant information out of a given tracefile.
1005 1007
1006 Args: 1008 Args:
1007 afile: is the filename string we will be processing. 1009 afile: is the filename string we will be processing.
1008 Returns: True if we successfully posted our data to storage.""" 1010 Returns: True if we successfully posted our data to storage."""
1009 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', 1011 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools',
1010 'testing', 'perf_testing')) 1012 'testing', 'perf_testing'))
1011 f = open(os.path.join(self.test.result_folder_name, afile)) 1013 f = open(os.path.join(self.test.result_folder_name, afile))
1012 tabulate_data = False 1014 tabulate_data = False
1013 revision_num = 0 1015 revision_num = 0
(...skipping 12 matching lines...) Expand all
1026 variant = result.group(1) 1028 variant = result.group(1)
1027 metric = result.group(2) 1029 metric = result.group(2)
1028 num = result.group(3) 1030 num = result.group(3)
1029 if num.find('.') == -1: 1031 if num.find('.') == -1:
1030 num = int(num) 1032 num = int(num)
1031 else: 1033 else:
1032 num = float(num) 1034 num = float(num)
1033 self.test.values_dict['commandline'][variant][metric] += [num] 1035 self.test.values_dict['commandline'][variant][metric] += [num]
1034 self.test.revision_dict['commandline'][variant][metric] += \ 1036 self.test.revision_dict['commandline'][variant][metric] += \
1035 [revision_num] 1037 [revision_num]
1036 if self.should_report_results(afile) and \ 1038 if not self.test.test_runner.no_upload and should_post_file:
1037 not self.test.test_runner.no_upload:
1038 upload_success = upload_success and self.report_results( 1039 upload_success = upload_success and self.report_results(
1039 metric, num, 'commandline', variant, revision_num, 1040 metric, num, 'commandline', variant, revision_num,
1040 self.CODE_SIZE) 1041 self.CODE_SIZE)
1041 else: 1042 else:
1042 upload_success = False 1043 upload_success = False
1043 1044
1044 f.close() 1045 f.close()
1045 return upload_success 1046 return upload_success
1046 1047
1047 class DromaeoSizeGrapher(Grapher): 1048 class DromaeoSizeGrapher(Grapher):
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 1124
1124 self.test.test_runner.run_cmd( 1125 self.test.test_runner.run_cmd(
1125 ['echo', '%d Generated checked total size' % total_size], 1126 ['echo', '%d Generated checked total size' % total_size],
1126 self.test.trace_file, append=True) 1127 self.test.trace_file, append=True)
1127 1128
1128 os.chdir('..') 1129 os.chdir('..')
1129 1130
1130 1131
1131 class CompileProcessor(Processor): 1132 class CompileProcessor(Processor):
1132 1133
1133 def process_file(self, afile): 1134 def process_file(self, afile, should_post_file):
1134 """Pull all the relevant information out of a given tracefile. 1135 """Pull all the relevant information out of a given tracefile.
1135 1136
1136 Args: 1137 Args:
1137 afile: is the filename string we will be processing. 1138 afile: is the filename string we will be processing.
1138 Returns: True if we successfully posted our data to storage.""" 1139 Returns: True if we successfully posted our data to storage."""
1139 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', 1140 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools',
1140 'testing', 'perf_testing')) 1141 'testing', 'perf_testing'))
1141 f = open(os.path.join(self.test.result_folder_name, afile)) 1142 f = open(os.path.join(self.test.result_folder_name, afile))
1142 tabulate_data = False 1143 tabulate_data = False
1143 revision_num = 0 1144 revision_num = 0
1144 upload_success = True 1145 upload_success = True
1145 for line in f.readlines(): 1146 for line in f.readlines():
1146 tokens = line.split() 1147 tokens = line.split()
1147 if 'Revision' in line: 1148 if 'Revision' in line:
1148 revision_num = int(line.split()[1]) 1149 revision_num = int(line.split()[1])
1149 else: 1150 else:
1150 for metric in self.test.values_list: 1151 for metric in self.test.values_list:
1151 if metric in line: 1152 if metric in line:
1152 num = tokens[0] 1153 num = tokens[0]
1153 if num.find('.') == -1: 1154 if num.find('.') == -1:
1154 num = int(num) 1155 num = int(num)
1155 else: 1156 else:
1156 num = float(num) 1157 num = float(num)
1157 self.test.values_dict['commandline']['frog'][metric] += [num] 1158 self.test.values_dict['commandline']['frog'][metric] += [num]
1158 self.test.revision_dict['commandline']['frog'][metric] += \ 1159 self.test.revision_dict['commandline']['frog'][metric] += \
1159 [revision_num] 1160 [revision_num]
1160 score_type = self.CODE_SIZE 1161 score_type = self.CODE_SIZE
1161 if 'Compiling' in metric or 'Bootstrapping' in metric: 1162 if 'Compiling' in metric or 'Bootstrapping' in metric:
1162 score_type = self.COMPILE_TIME 1163 score_type = self.COMPILE_TIME
1163 if self.should_report_results(afile) and \ 1164 if not self.test.test_runner.no_upload and should_post_file:
1164 not self.test.test_runner.no_upload:
1165 if num < self.test.failure_threshold[metric]: 1165 if num < self.test.failure_threshold[metric]:
1166 num = 0 1166 num = 0
1167 upload_success = upload_success and self.report_results( 1167 upload_success = upload_success and self.report_results(
1168 metric, num, 'commandline', 'frog', revision_num, 1168 metric, num, 'commandline', 'frog', revision_num,
1169 score_type) 1169 score_type)
1170 else: 1170 else:
1171 upload_success = False 1171 upload_success = False
1172 if revision_num != 0: 1172 if revision_num != 0:
1173 for metric in self.test.values_list: 1173 for metric in self.test.values_list:
1174 self.test.revision_dict['commandline']['frog'][metric].pop() 1174 self.test.revision_dict['commandline']['frog'][metric].pop()
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 while True: 1213 while True:
1214 if runner.has_new_code(): 1214 if runner.has_new_code():
1215 runner.run_test_sequence() 1215 runner.run_test_sequence()
1216 else: 1216 else:
1217 time.sleep(200) 1217 time.sleep(200)
1218 else: 1218 else:
1219 runner.run_test_sequence() 1219 runner.run_test_sequence()
1220 1220
1221 if __name__ == '__main__': 1221 if __name__ == '__main__':
1222 main() 1222 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698