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 getpass | 8 import getpass |
| 9 import math | 9 import math |
| 10 from matplotlib.font_manager import FontProperties | 10 from matplotlib.font_manager import FontProperties |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 COMMAND_LINE = 'commandline' | 50 COMMAND_LINE = 'commandline' |
| 51 JS = 'js' | 51 JS = 'js' |
| 52 FROG = 'frog' | 52 FROG = 'frog' |
| 53 JS_AND_FROG = [JS, FROG] | 53 JS_AND_FROG = [JS, FROG] |
| 54 COLORS = ['blue', 'green', 'red', 'cyan', 'magenta', 'black'] | 54 COLORS = ['blue', 'green', 'red', 'cyan', 'magenta', 'black'] |
| 55 GRAPH_OUT_DIR = 'graphs' | 55 GRAPH_OUT_DIR = 'graphs' |
| 56 | 56 |
| 57 BROWSER_PERF = 'browser-perf' | 57 BROWSER_PERF = 'browser-perf' |
| 58 TIME_SIZE = 'code-time-size' | 58 TIME_SIZE = 'code-time-size' |
| 59 CL_PERF = 'cl-results' | 59 CL_PERF = 'cl-results' |
| 60 # TODO(vsm): Merge these? | |
| 60 DROMAEO = 'dromaeo' | 61 DROMAEO = 'dromaeo' |
| 62 DROMAEO_SIZE = 'dromaeo-size' | |
| 61 | 63 |
| 62 SLEEP_TIME = 200 | 64 SLEEP_TIME = 200 |
| 63 VERBOSE = False | 65 VERBOSE = False |
| 64 HAS_SHELL = False | 66 HAS_SHELL = False |
| 65 if platform.system() == 'Windows': | 67 if platform.system() == 'Windows': |
| 66 # On Windows, shell must be true to get the correct environment variables. | 68 # On Windows, shell must be true to get the correct environment variables. |
| 67 HAS_SHELL = True | 69 HAS_SHELL = True |
| 68 | 70 |
| 69 """First, some utility methods.""" | 71 """First, some utility methods.""" |
| 70 | 72 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 r = re.match(result_pattern, result) | 627 r = re.match(result_pattern, result) |
| 626 name = r.group(1).strip(':').replace(' ', '_') | 628 name = r.group(1).strip(':').replace(' ', '_') |
| 627 score = float(r.group(2)) | 629 score = float(r.group(2)) |
| 628 bench_dict[name] += [float(score)] | 630 bench_dict[name] += [float(score)] |
| 629 self.revision_dict[browser][version][name] += [revision_num] | 631 self.revision_dict[browser][version][name] += [revision_num] |
| 630 | 632 |
| 631 f.close() | 633 f.close() |
| 632 self.calculate_geometric_mean(browser, version, revision_num) | 634 self.calculate_geometric_mean(browser, version, revision_num) |
| 633 | 635 |
| 634 | 636 |
| 637 class DromaeoSizeTest(TestRunner): | |
|
Emily Fortuna
2012/04/03 01:00:35
This works... it seems like it might be less verbo
vsm
2012/04/03 18:18:22
That was my original intent, but it's a non-trivia
| |
| 638 """Run tests to determine the compiled | |
| 639 file output size of Dromaeo.""" | |
|
Emily Fortuna
2012/04/03 01:00:35
This comment can probably be all on line line.
vsm
2012/04/03 18:18:22
Done.
| |
| 640 def __init__(self): | |
| 641 super(DromaeoSizeTest, self).__init__( | |
| 642 DROMAEO_SIZE, | |
| 643 ['browser'], ['dart', 'frog_dom', 'frog_html', 'frog_htmlidiomatic'], | |
| 644 ['attr', 'modify', 'query', 'traverse']) | |
| 645 | |
| 646 def run_tests(self): | |
| 647 # Build tests. | |
| 648 dromaeo_path = os.path.join('samples', 'third_party', 'dromaeo') | |
| 649 current_path = os.getcwd() | |
| 650 os.chdir(dromaeo_path) | |
| 651 run_cmd(['python', os.path.join('generate_frog_tests.py')]) | |
| 652 os.chdir(current_path) | |
| 653 | |
| 654 self.trace_file = os.path.join('tools', 'testing', 'perf_testing', | |
| 655 self.result_folder_name, self.result_folder_name + self.cur_time) | |
| 656 self.add_svn_revision_to_trace(self.trace_file) | |
| 657 | |
| 658 variants = [ | |
| 659 ('frog_dom', ''), | |
| 660 ('frog_html', '-html'), | |
| 661 ('frog_htmlidiomatic', '-htmlidiomatic')] | |
| 662 | |
| 663 test_path = os.path.join(dromaeo_path, 'tests') | |
| 664 frog_path = os.path.join(test_path, 'frog') | |
| 665 total_size = {} | |
| 666 for (variant, _) in variants: | |
| 667 total_size[variant] = 0 | |
| 668 total_dart_size = 0 | |
| 669 for suite in ['attr', 'modify', 'query', 'traverse']: | |
| 670 dart_size = 0 | |
| 671 try: | |
| 672 dart_size = os.path.getsize(os.path.join(test_path, | |
| 673 'dom-%s.dart' % suite)) | |
| 674 except OSError: | |
| 675 pass #If compilation failed, continue on running other tests. | |
| 676 | |
| 677 total_dart_size += dart_size | |
| 678 run_cmd(['echo', 'Size (dart, %s): %s' % (suite, str(dart_size))], | |
| 679 self.trace_file, append=True) | |
| 680 | |
| 681 for (variant, suffix) in variants: | |
| 682 name = 'dom-%s%s.dart.js' % (suite, suffix) | |
| 683 js_size = 0 | |
| 684 try: | |
| 685 # TODO(vsm): Strip comments at least. Consider compression. | |
| 686 js_size = os.path.getsize(os.path.join(frog_path, name)) | |
| 687 except OSError: | |
| 688 pass #If compilation failed, continue on running other tests. | |
| 689 | |
| 690 total_size[variant] += js_size | |
| 691 run_cmd(['echo', 'Size (%s, %s): %s' % (variant, suite, | |
| 692 str(js_size))], | |
| 693 self.trace_file, append=True) | |
| 694 | |
| 695 # TODO(vsm): Change GEO_MEAN to sum. The base class assumes | |
| 696 # GEO_MEAN right now. | |
| 697 run_cmd(['echo', 'Size (dart, %s): %s' % (total_dart_size, GEO_MEAN)], | |
| 698 self.trace_file, append=True) | |
| 699 for (variant, _) in variants: | |
| 700 run_cmd(['echo', 'Size (%s, %s): %s' % (variant, GEO_MEAN, | |
| 701 total_size[variant])], | |
| 702 self.trace_file, append=True) | |
| 703 | |
| 704 | |
| 705 def process_file(self, afile): | |
| 706 """Pull all the relevant information out of a given tracefile. | |
| 707 | |
| 708 Args: | |
| 709 afile: is the filename string we will be processing.""" | |
| 710 os.chdir(os.path.join(DART_INSTALL_LOCATION, 'tools', 'testing', | |
| 711 'perf_testing')) | |
| 712 f = open(os.path.join(self.result_folder_name, afile)) | |
| 713 tabulate_data = False | |
| 714 revision_num = 0 | |
| 715 revision_pattern = r'Revision: (\d+)' | |
| 716 result_pattern = r'Size \((\w+), ([a-zA-Z0-9-]+)\): (\d+)' | |
| 717 | |
| 718 for line in f.readlines(): | |
| 719 rev = re.match(revision_pattern, line.strip()) | |
| 720 if rev: | |
| 721 revision_num = int(rev.group(1)) | |
| 722 continue | |
| 723 | |
| 724 result = re.match(result_pattern, line.strip()) | |
| 725 if result: | |
| 726 variant = result.group(1) | |
| 727 metric = result.group(2) | |
| 728 num = result.group(3) | |
| 729 if num.find('.') == -1: | |
| 730 num = int(num) | |
| 731 else: | |
| 732 num = float(num) | |
| 733 self.values_dict['browser'][variant][metric] += [num] | |
| 734 self.revision_dict['browser'][variant][metric] += [revision_num] | |
| 735 | |
| 736 f.close() | |
| 737 | |
| 738 def plot_results(self, png_filename): | |
| 739 self.style_and_save_perf_plot( | |
| 740 'Compiled Dromaeo Sizes', | |
| 741 'Size (in bytes)', 10, 10, 'lower left', png_filename, | |
| 742 ['browser'], ['dart', 'frog_dom', 'frog_html', 'frog_htmlidiomatic'], | |
| 743 ['attr', 'modify', 'query', 'traverse']) | |
| 744 | |
| 745 self.style_and_save_perf_plot( | |
| 746 'Compiled Dromaeo Sizes', | |
| 747 'Size (in bytes)', 10, 10, 'lower left', '2' + png_filename, | |
| 748 ['browser'], ['dart', 'frog_dom', 'frog_html', 'frog_htmlidiomatic'], | |
| 749 [GEO_MEAN]) | |
| 750 | |
| 751 | |
| 752 | |
| 635 class CompileTimeAndSizeTest(TestRunner): | 753 class CompileTimeAndSizeTest(TestRunner): |
| 636 """Run tests to determine how long minfrog takes to compile, and the compiled | 754 """Run tests to determine how long minfrog takes to compile, and the compiled |
| 637 file output size of some benchmarking files.""" | 755 file output size of some benchmarking files.""" |
| 638 def __init__(self): | 756 def __init__(self): |
| 639 super(CompileTimeAndSizeTest, self).__init__(TIME_SIZE, | 757 super(CompileTimeAndSizeTest, self).__init__(TIME_SIZE, |
| 640 [COMMAND_LINE], [FROG], ['Compiling on Dart VM', 'Bootstrapping', | 758 [COMMAND_LINE], [FROG], ['Compiling on Dart VM', 'Bootstrapping', |
| 641 'minfrog', 'swarm', 'total']) | 759 'minfrog', 'swarm', 'total']) |
| 642 self.failure_threshold = {'Compiling on Dart VM' : 1, 'Bootstrapping' : .5, | 760 self.failure_threshold = {'Compiling on Dart VM' : 1, 'Bootstrapping' : .5, |
| 643 'minfrog' : 100, 'swarm' : 100, 'total' : 100} | 761 'minfrog' : 100, 'swarm' : 100, 'total' : 100} |
| 644 | 762 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 action='store_true', default=False) | 862 action='store_true', default=False) |
| 745 parser.add_option('--size-time', '-s', dest='size', | 863 parser.add_option('--size-time', '-s', dest='size', |
| 746 help='Run the code size and timing tests', | 864 help='Run the code size and timing tests', |
| 747 action='store_true', default=False) | 865 action='store_true', default=False) |
| 748 parser.add_option('--browser-perf', '-b', dest='perf', | 866 parser.add_option('--browser-perf', '-b', dest='perf', |
| 749 help='Run the browser performance tests', | 867 help='Run the browser performance tests', |
| 750 action='store_true', default=False) | 868 action='store_true', default=False) |
| 751 parser.add_option('--dromaeo', '-d', dest='dromaeo', | 869 parser.add_option('--dromaeo', '-d', dest='dromaeo', |
| 752 help='Run the Dromaeo performance tests', | 870 help='Run the Dromaeo performance tests', |
| 753 action='store_true', default=False) | 871 action='store_true', default=False) |
| 872 parser.add_option('--dromaeo-size', '-D', dest='dsize', | |
| 873 help='Run the Dromaeo size tests', | |
| 874 action='store_true', default=False) | |
| 754 parser.add_option('--forever', '-f', dest='continuous', | 875 parser.add_option('--forever', '-f', dest='continuous', |
| 755 help='Run this script forever, always checking for the next svn ' | 876 help='Run this script forever, always checking for the next svn ' |
| 756 'checkin', action='store_true', default=False) | 877 'checkin', action='store_true', default=False) |
| 757 parser.add_option('--verbose', '-v', dest='verbose', | 878 parser.add_option('--verbose', '-v', dest='verbose', |
| 758 help='Print extra debug output', action='store_true', default=False) | 879 help='Print extra debug output', action='store_true', default=False) |
| 759 parser.add_option('--nobuild', '-n', dest='no_build', action='store_true', | 880 parser.add_option('--nobuild', '-n', dest='no_build', action='store_true', |
| 760 help='Do not sync with the repository and do not rebuild.', default=False) | 881 help='Do not sync with the repository and do not rebuild.', default=False) |
| 761 parser.add_option('--graph-only', '-g', dest='graph_only', default=False, | 882 parser.add_option('--graph-only', '-g', dest='graph_only', default=False, |
| 762 help='Do not run tests, only regenerate graphs', action='store_true') | 883 help='Do not run tests, only regenerate graphs', action='store_true') |
| 763 parser.add_option('--user', '-u', dest='username', | 884 parser.add_option('--user', '-u', dest='username', |
| 764 help='Username for submitting new data to App Engine', default='') | 885 help='Username for submitting new data to App Engine', default='') |
| 765 | 886 |
| 766 args, ignored = parser.parse_args() | 887 args, ignored = parser.parse_args() |
| 767 password = '' | 888 password = '' |
| 768 if args.username != '': | 889 if args.username != '': |
| 769 password = getpass.getpass("App Engine Password: ") | 890 password = getpass.getpass("App Engine Password: ") |
| 770 else: | 891 else: |
| 771 print 'Warning: performance data will not be uploaded to App Engine' + \ | 892 print 'Warning: performance data will not be uploaded to App Engine' + \ |
| 772 ' if you do not provide a username.' | 893 ' if you do not provide a username.' |
| 773 if not (args.cl or args.size or args.perf or args.dromaeo): | 894 if not (args.cl or args.size or args.perf or args.dromaeo or args.dsize): |
| 774 args.cl = args.size = args.perf = args.dromaeo = True | 895 args.cl = args.size = args.perf = args.dromaeo = args.dsize = True |
| 775 return (args.cl, args.size, args.perf, args.dromaeo, args.continuous, | 896 return (args.cl, args.size, args.perf, args.dromaeo, args.dsize, |
| 776 args.verbose, args.no_build, args.graph_only, | 897 args.continuous, args.verbose, args.no_build, args.graph_only, |
| 777 args.username, password) | 898 args.username, password) |
| 778 | 899 |
| 779 def run_test_sequence(cl, size, perf, dromaeo, no_build, graph_only, | 900 def run_test_sequence(cl, size, perf, dromaeo, dsize, no_build, graph_only, |
| 780 username, password): | 901 username, password): |
| 781 # The buildbot already builds and syncs to a specific revision. Don't fight | 902 # The buildbot already builds and syncs to a specific revision. Don't fight |
| 782 # with it or replicate work. | 903 # with it or replicate work. |
| 783 if (not no_build or not graph_only) and sync_and_build() == 1: | 904 if (not no_build or not graph_only) and sync_and_build() == 1: |
| 784 return # The build is broken. | 905 return # The build is broken. |
| 785 if size: | 906 if size: |
| 786 CompileTimeAndSizeTest().run(graph_only) | 907 CompileTimeAndSizeTest().run(graph_only) |
| 787 if cl: | 908 if cl: |
| 788 CommandLinePerformanceTest().run(graph_only) | 909 CommandLinePerformanceTest().run(graph_only) |
| 789 if perf: | 910 if perf: |
| 790 BrowserStandalonePerformanceTest().run(graph_only) | 911 BrowserStandalonePerformanceTest().run(graph_only) |
| 791 if dromaeo: | 912 if dromaeo: |
| 792 DromaeoTest().run(graph_only) | 913 DromaeoTest().run(graph_only) |
| 914 if dsize: | |
| 915 DromaeoSizeTest().run(graph_only) | |
| 793 | 916 |
| 794 if username != '': | 917 if username != '': |
| 795 upload_to_app_engine(username, password) | 918 upload_to_app_engine(username, password) |
| 796 | 919 |
| 797 def main(): | 920 def main(): |
| 798 global VERBOSE | 921 global VERBOSE |
| 799 (cl, size, perf, dromaeo, continuous, verbose, no_build, graph_only, | 922 (cl, size, perf, dromaeo, dsize, continuous, verbose, no_build, graph_only, |
| 800 username, password) = parse_args() | 923 username, password) = parse_args() |
| 801 VERBOSE = verbose | 924 VERBOSE = verbose |
| 802 if continuous: | 925 if continuous: |
| 803 while True: | 926 while True: |
| 804 if has_new_code(): | 927 if has_new_code(): |
| 805 run_test_sequence(cl, size, perf, dromaeo, no_build, graph_only, | 928 run_test_sequence(cl, size, perf, dromaeo, dsize, no_build, graph_only, |
| 806 username, password) | 929 username, password) |
| 807 else: | 930 else: |
| 808 time.sleep(SLEEP_TIME) | 931 time.sleep(SLEEP_TIME) |
| 809 else: | 932 else: |
| 810 run_test_sequence(cl, size, perf, dromaeo, no_build, graph_only, | 933 run_test_sequence(cl, size, perf, dromaeo, dsize, no_build, graph_only, |
| 811 username, password) | 934 username, password) |
| 812 | 935 |
| 813 if __name__ == '__main__': | 936 if __name__ == '__main__': |
| 814 main() | 937 main() |
| OLD | NEW |