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 getpass | 8 import getpass |
9 import math | 9 import math |
10 from matplotlib.font_manager import FontProperties | 10 try: |
11 import matplotlib.pyplot as plt | 11 from matplotlib.font_manager import FontProperties |
| 12 import matplotlib.pyplot as plt |
| 13 except ImportError: |
| 14 pass # Only needed if we want to make graphs. |
12 import optparse | 15 import optparse |
13 import os | 16 import os |
14 from os.path import dirname, abspath | 17 from os.path import dirname, abspath |
15 import platform | 18 import platform |
16 import re | 19 import re |
17 import shutil | 20 import shutil |
18 import stat | 21 import stat |
19 import subprocess | 22 import subprocess |
20 import sys | 23 import sys |
21 import time | 24 import time |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 os.chdir(os.path.join('tools', 'testing', 'perf_testing')) | 371 os.chdir(os.path.join('tools', 'testing', 'perf_testing')) |
369 | 372 |
370 # TODO(efortuna): You will want to make this only use a subset of the files | 373 # TODO(efortuna): You will want to make this only use a subset of the files |
371 # eventually. | 374 # eventually. |
372 files = os.listdir(self.result_folder_name) | 375 files = os.listdir(self.result_folder_name) |
373 | 376 |
374 for afile in files: | 377 for afile in files: |
375 if not afile.startswith('.'): | 378 if not afile.startswith('.'): |
376 self.process_file(afile) | 379 self.process_file(afile) |
377 | 380 |
378 self.plot_results('%s.png' % self.result_folder_name) | 381 if 'plt' in globals(): |
| 382 # Only run Matplotlib if it is installed. |
| 383 self.plot_results('%s.png' % self.result_folder_name) |
| 384 else: |
| 385 print 'Unable to import Matplotlib and therefore unable to generate ' + \ |
| 386 'graphs. Please install it for this version of Python.' |
379 | 387 |
380 class PerformanceTest(TestRunner): | 388 class PerformanceTest(TestRunner): |
381 """Super class for all performance testing.""" | 389 """Super class for all performance testing.""" |
382 def __init__(self, result_folder_name, platform_list, platform_type, | 390 def __init__(self, result_folder_name, platform_list, platform_type, |
383 versions, benchmarks): | 391 versions, benchmarks): |
384 super(PerformanceTest, self).__init__(result_folder_name, | 392 super(PerformanceTest, self).__init__(result_folder_name, |
385 platform_list, versions, benchmarks) | 393 platform_list, versions, benchmarks) |
386 self.platform_list = platform_list | 394 self.platform_list = platform_list |
387 self.platform_type = platform_type | 395 self.platform_type = platform_type |
388 self.versions = versions | 396 self.versions = versions |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 else: | 943 else: |
936 print 'Error: Invalid suite %s not in %s' % (name, | 944 print 'Error: Invalid suite %s not in %s' % (name, |
937 ','.join(SUITES.keys())) | 945 ','.join(SUITES.keys())) |
938 sys.exit(1) | 946 sys.exit(1) |
939 return (suites, args.continuous, args.verbose, args.no_build, | 947 return (suites, args.continuous, args.verbose, args.no_build, |
940 args.graph_only, args.upload) | 948 args.graph_only, args.upload) |
941 | 949 |
942 def run_test_sequence(suites, no_build, graph_only, upload): | 950 def run_test_sequence(suites, no_build, graph_only, upload): |
943 # The buildbot already builds and syncs to a specific revision. Don't fight | 951 # The buildbot already builds and syncs to a specific revision. Don't fight |
944 # with it or replicate work. | 952 # with it or replicate work. |
945 if (not no_build or not graph_only) and sync_and_build() == 1: | 953 if not no_build and sync_and_build() == 1: |
946 return # The build is broken. | 954 return # The build is broken. |
947 | 955 |
948 for test in suites: | 956 for test in suites: |
949 test().run(graph_only) | 957 test().run(graph_only) |
950 | 958 |
951 if upload: | 959 if upload: |
952 upload_to_app_engine(SUITES.keys()) | 960 upload_to_app_engine(SUITES.keys()) |
953 | 961 |
954 def main(): | 962 def main(): |
955 global VERBOSE | 963 global VERBOSE |
956 (suites, continuous, verbose, no_build, graph_only, upload) = parse_args() | 964 (suites, continuous, verbose, no_build, graph_only, upload) = parse_args() |
957 VERBOSE = verbose | 965 VERBOSE = verbose |
958 if continuous: | 966 if continuous: |
959 while True: | 967 while True: |
960 if has_new_code(): | 968 if has_new_code(): |
961 run_test_sequence(suites, no_build, graph_only, upload) | 969 run_test_sequence(suites, no_build, graph_only, upload) |
962 else: | 970 else: |
963 time.sleep(SLEEP_TIME) | 971 time.sleep(SLEEP_TIME) |
964 else: | 972 else: |
965 run_test_sequence(suites, no_build, graph_only, upload) | 973 run_test_sequence(suites, no_build, graph_only, upload) |
966 | 974 |
967 if __name__ == '__main__': | 975 if __name__ == '__main__': |
968 main() | 976 main() |
OLD | NEW |