Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ | 6 """ |
| 7 Performance runner for d8. | 7 Performance runner for d8. |
| 8 | 8 |
| 9 Call e.g. with tools/run-perf.py --arch ia32 some_suite.json | 9 Call e.g. with tools/run-perf.py --arch ia32 some_suite.json |
| 10 | 10 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 """Represents a node in the suite tree structure.""" | 343 """Represents a node in the suite tree structure.""" |
| 344 def __init__(self, *args): | 344 def __init__(self, *args): |
| 345 self._children = [] | 345 self._children = [] |
| 346 | 346 |
| 347 def AppendChild(self, child): | 347 def AppendChild(self, child): |
| 348 self._children.append(child) | 348 self._children.append(child) |
| 349 | 349 |
| 350 | 350 |
| 351 class DefaultSentinel(Node): | 351 class DefaultSentinel(Node): |
| 352 """Fake parent node with all default values.""" | 352 """Fake parent node with all default values.""" |
| 353 def __init__(self): | 353 def __init__(self, binary = "d8"): |
| 354 super(DefaultSentinel, self).__init__() | 354 super(DefaultSentinel, self).__init__() |
| 355 self.binary = "d8" | 355 self.binary = binary |
| 356 self.run_count = 10 | 356 self.run_count = 10 |
| 357 self.timeout = 60 | 357 self.timeout = 60 |
| 358 self.path = [] | 358 self.path = [] |
| 359 self.graphs = [] | 359 self.graphs = [] |
| 360 self.flags = [] | 360 self.flags = [] |
| 361 self.test_flags = [] | 361 self.test_flags = [] |
| 362 self.resources = [] | 362 self.resources = [] |
| 363 self.results_regexp = None | 363 self.results_regexp = None |
| 364 self.stddev_regexp = None | 364 self.stddev_regexp = None |
| 365 self.units = "score" | 365 self.units = "score" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 # This is a generic suite definition. It is either a runnable executable | 536 # This is a generic suite definition. It is either a runnable executable |
| 537 # or has a main js file. | 537 # or has a main js file. |
| 538 return RunnableGenericConfig(suite, parent, arch) | 538 return RunnableGenericConfig(suite, parent, arch) |
| 539 elif suite.get("tests"): | 539 elif suite.get("tests"): |
| 540 # This is neither a leaf nor a runnable. | 540 # This is neither a leaf nor a runnable. |
| 541 return GraphConfig(suite, parent, arch) | 541 return GraphConfig(suite, parent, arch) |
| 542 else: # pragma: no cover | 542 else: # pragma: no cover |
| 543 raise Exception("Invalid suite configuration.") | 543 raise Exception("Invalid suite configuration.") |
| 544 | 544 |
| 545 | 545 |
| 546 def BuildGraphConfigs(suite, arch, parent=None): | 546 def BuildGraphConfigs(suite, arch, parent): |
| 547 """Builds a tree structure of graph objects that corresponds to the suite | 547 """Builds a tree structure of graph objects that corresponds to the suite |
| 548 configuration. | 548 configuration. |
| 549 """ | 549 """ |
| 550 parent = parent or DefaultSentinel() | |
| 551 | 550 |
| 552 # TODO(machenbach): Implement notion of cpu type? | 551 # TODO(machenbach): Implement notion of cpu type? |
| 553 if arch not in suite.get("archs", SUPPORTED_ARCHS): | 552 if arch not in suite.get("archs", SUPPORTED_ARCHS): |
| 554 return None | 553 return None |
| 555 | 554 |
| 556 graph = MakeGraphConfig(suite, arch, parent) | 555 graph = MakeGraphConfig(suite, arch, parent) |
| 557 for subsuite in suite.get("tests", []): | 556 for subsuite in suite.get("tests", []): |
| 558 BuildGraphConfigs(subsuite, arch, graph) | 557 BuildGraphConfigs(subsuite, arch, graph) |
| 559 parent.AppendChild(graph) | 558 parent.AppendChild(graph) |
| 560 return graph | 559 return graph |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 806 default="") | 805 default="") |
| 807 parser.add_option("--json-test-results", | 806 parser.add_option("--json-test-results", |
| 808 help="Path to a file for storing json results.") | 807 help="Path to a file for storing json results.") |
| 809 parser.add_option("--json-test-results-no-patch", | 808 parser.add_option("--json-test-results-no-patch", |
| 810 help="Path to a file for storing json results from run " | 809 help="Path to a file for storing json results from run " |
| 811 "without patch.") | 810 "without patch.") |
| 812 parser.add_option("--outdir", help="Base directory with compile output", | 811 parser.add_option("--outdir", help="Base directory with compile output", |
| 813 default="out") | 812 default="out") |
| 814 parser.add_option("--outdir-no-patch", | 813 parser.add_option("--outdir-no-patch", |
| 815 help="Base directory with compile output without patch") | 814 help="Base directory with compile output without patch") |
| 815 parser.add_option("--binary-override-path", | |
| 816 help="JavaScript engine binary. By default, d8 under " | |
| 817 "architecture-specific build dir. " | |
| 818 "Not supported in conjunction with outdir-no-patch.") | |
| 819 | |
| 816 (options, args) = parser.parse_args(args) | 820 (options, args) = parser.parse_args(args) |
| 817 | 821 |
| 818 if len(args) == 0: # pragma: no cover | 822 if len(args) == 0: # pragma: no cover |
| 819 parser.print_help() | 823 parser.print_help() |
| 820 return 1 | 824 return 1 |
| 821 | 825 |
| 822 if options.arch in ["auto", "native"]: # pragma: no cover | 826 if options.arch in ["auto", "native"]: # pragma: no cover |
| 823 options.arch = ARCH_GUESS | 827 options.arch = ARCH_GUESS |
| 824 | 828 |
| 825 if not options.arch in SUPPORTED_ARCHS: # pragma: no cover | 829 if not options.arch in SUPPORTED_ARCHS: # pragma: no cover |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 836 "patch must be specified.") | 840 "patch must be specified.") |
| 837 return 1 | 841 return 1 |
| 838 | 842 |
| 839 workspace = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) | 843 workspace = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
| 840 | 844 |
| 841 if options.buildbot: | 845 if options.buildbot: |
| 842 build_config = "Release" | 846 build_config = "Release" |
| 843 else: | 847 else: |
| 844 build_config = "%s.release" % options.arch | 848 build_config = "%s.release" % options.arch |
| 845 | 849 |
| 846 options.shell_dir = os.path.join(workspace, options.outdir, build_config) | 850 if options.binary_override_path == None: |
| 851 options.shell_dir = os.path.join(workspace, options.outdir, build_config) | |
| 852 default_binary_name = "d8" | |
| 853 else: | |
| 854 if not os.path.isfile(options.binary_override_path): | |
| 855 print "binary-override-path must be a file name" | |
| 856 return 1 | |
| 857 if options.outdir_no_patch: | |
| 858 print "specify either binary-override-path or shell-dir-no-patch" | |
|
Michael Achenbach
2016/02/01 20:02:24
nit: The option is called outdir-no-patch.
Mircea Trofin
2016/02/01 20:25:53
Done.
| |
| 859 return 1 | |
| 860 options.shell_dir = os.path.dirname(options.binary_override_path) | |
| 861 default_binary_name = os.path.basename(options.binary_override_path) | |
| 847 | 862 |
| 848 if options.outdir_no_patch: | 863 if options.outdir_no_patch: |
| 849 options.shell_dir_no_patch = os.path.join( | 864 options.shell_dir_no_patch = os.path.join( |
| 850 workspace, options.outdir_no_patch, build_config) | 865 workspace, options.outdir_no_patch, build_config) |
| 851 else: | 866 else: |
| 852 options.shell_dir_no_patch = None | 867 options.shell_dir_no_patch = None |
| 853 | 868 |
| 854 platform = Platform.GetPlatform(options) | 869 platform = Platform.GetPlatform(options) |
| 855 | 870 |
| 856 results = Results() | 871 results = Results() |
| 857 results_no_patch = Results() | 872 results_no_patch = Results() |
| 858 for path in args: | 873 for path in args: |
| 859 path = os.path.abspath(path) | 874 path = os.path.abspath(path) |
| 860 | 875 |
| 861 if not os.path.exists(path): # pragma: no cover | 876 if not os.path.exists(path): # pragma: no cover |
| 862 results.errors.append("Configuration file %s does not exist." % path) | 877 results.errors.append("Configuration file %s does not exist." % path) |
| 863 continue | 878 continue |
| 864 | 879 |
| 865 with open(path) as f: | 880 with open(path) as f: |
| 866 suite = json.loads(f.read()) | 881 suite = json.loads(f.read()) |
| 867 | 882 |
| 868 # If no name is given, default to the file name without .json. | 883 # If no name is given, default to the file name without .json. |
| 869 suite.setdefault("name", os.path.splitext(os.path.basename(path))[0]) | 884 suite.setdefault("name", os.path.splitext(os.path.basename(path))[0]) |
| 870 | 885 |
| 871 # Setup things common to one test suite. | 886 # Setup things common to one test suite. |
| 872 platform.PreExecution() | 887 platform.PreExecution() |
| 873 | 888 |
| 874 # Build the graph/trace tree structure. | 889 # Build the graph/trace tree structure. |
| 875 root = BuildGraphConfigs(suite, options.arch) | 890 default_parent = DefaultSentinel(default_binary_name) |
| 891 root = BuildGraphConfigs(suite, options.arch, default_parent) | |
| 876 | 892 |
| 877 # Callback to be called on each node on traversal. | 893 # Callback to be called on each node on traversal. |
| 878 def NodeCB(node): | 894 def NodeCB(node): |
| 879 platform.PreTests(node, path) | 895 platform.PreTests(node, path) |
| 880 | 896 |
| 881 # Traverse graph/trace tree and interate over all runnables. | 897 # Traverse graph/trace tree and interate over all runnables. |
| 882 for runnable in FlattenRunnables(root, NodeCB): | 898 for runnable in FlattenRunnables(root, NodeCB): |
| 883 print ">>> Running suite: %s" % "/".join(runnable.graphs) | 899 print ">>> Running suite: %s" % "/".join(runnable.graphs) |
| 884 | 900 |
| 885 def Runner(): | 901 def Runner(): |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 903 | 919 |
| 904 if options.json_test_results_no_patch: | 920 if options.json_test_results_no_patch: |
| 905 results_no_patch.WriteToFile(options.json_test_results_no_patch) | 921 results_no_patch.WriteToFile(options.json_test_results_no_patch) |
| 906 else: # pragma: no cover | 922 else: # pragma: no cover |
| 907 print results_no_patch | 923 print results_no_patch |
| 908 | 924 |
| 909 return min(1, len(results.errors)) | 925 return min(1, len(results.errors)) |
| 910 | 926 |
| 911 if __name__ == "__main__": # pragma: no cover | 927 if __name__ == "__main__": # pragma: no cover |
| 912 sys.exit(Main(sys.argv[1:])) | 928 sys.exit(Main(sys.argv[1:])) |
| OLD | NEW |