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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 stdout = self._Run(runnable, count, no_patch=False) | 605 stdout = self._Run(runnable, count, no_patch=False) |
| 606 if self.shell_dir_no_patch: | 606 if self.shell_dir_no_patch: |
| 607 return stdout, self._Run(runnable, count, no_patch=True) | 607 return stdout, self._Run(runnable, count, no_patch=True) |
| 608 else: | 608 else: |
| 609 return stdout, None | 609 return stdout, None |
| 610 | 610 |
| 611 | 611 |
| 612 class DesktopPlatform(Platform): | 612 class DesktopPlatform(Platform): |
| 613 def __init__(self, options): | 613 def __init__(self, options): |
| 614 super(DesktopPlatform, self).__init__(options) | 614 super(DesktopPlatform, self).__init__(options) |
| 615 self.command_prefix = [] | |
| 616 if options.prioritize or options.affinitize != None: | |
| 617 self.command_prefix = ["sudo", "schedtool"] | |
| 618 if options.prioritize: | |
| 619 self.command_prefix += ["-p", "-20"] | |
|
Michael Achenbach
2016/04/27 14:55:00
My documentation says:
-p STATIC_PRIORITY u
Mircea Trofin
2016/04/27 15:56:35
Ugh. should be -n, not -p. Thanks.
| |
| 620 if options.affinitize != None: | |
| 621 # schedtool expects a bit pattern when setting affinity, where each | |
| 622 # bit set to '1' corresponds to a core where the process may run on. | |
| 623 # 0 corresponds to CPU 0. Since the 'affinitize' parameter is a core numbe r, we need | |
| 624 # to map to said bit pattern. | |
| 625 core = (1 << int(options.affinitize)) - 1 | |
| 626 self.command_prefix += ["-a", str(core)] | |
|
Michael Achenbach
2016/04/27 14:55:00
So if options.affinitize == 2, this is set to "-a
Mircea Trofin
2016/04/27 15:56:35
Oh, that's a bug, indeed. It should be core = if
Michael Achenbach
2016/04/27 17:23:29
Could you add in a comment an example of how this
Mircea Trofin
2016/04/28 02:07:24
Done.
| |
| 627 self.command_prefix += ["-e"] | |
| 615 | 628 |
| 616 def PreExecution(self): | 629 def PreExecution(self): |
| 617 pass | 630 pass |
| 618 | 631 |
| 619 def PostExecution(self): | 632 def PostExecution(self): |
| 620 pass | 633 pass |
| 621 | 634 |
| 622 def PreTests(self, node, path): | 635 def PreTests(self, node, path): |
| 623 if isinstance(node, RunnableConfig): | 636 if isinstance(node, RunnableConfig): |
| 624 node.ChangeCWD(path) | 637 node.ChangeCWD(path) |
| 625 | 638 |
| 626 def _Run(self, runnable, count, no_patch=False): | 639 def _Run(self, runnable, count, no_patch=False): |
| 627 suffix = ' - without patch' if no_patch else '' | 640 suffix = ' - without patch' if no_patch else '' |
| 628 shell_dir = self.shell_dir_no_patch if no_patch else self.shell_dir | 641 shell_dir = self.shell_dir_no_patch if no_patch else self.shell_dir |
| 629 title = ">>> %%s (#%d)%s:" % ((count + 1), suffix) | 642 title = ">>> %%s (#%d)%s:" % ((count + 1), suffix) |
| 643 command = self.command_prefix + runnable.GetCommand(shell_dir, self.extra_fl ags) | |
| 630 try: | 644 try: |
| 631 output = commands.Execute( | 645 output = commands.Execute( |
| 632 runnable.GetCommand(shell_dir, self.extra_flags), | 646 command, |
| 633 timeout=runnable.timeout, | 647 timeout=runnable.timeout, |
| 634 ) | 648 ) |
| 635 except OSError as e: # pragma: no cover | 649 except OSError as e: # pragma: no cover |
| 636 print title % "OSError" | 650 print title % "OSError" |
| 637 print e | 651 print e |
| 638 return "" | 652 return "" |
| 639 print title % "Stdout" | 653 print title % "Stdout" |
| 640 print output.stdout | 654 print output.stdout |
| 641 if output.stderr: # pragma: no cover | 655 if output.stderr: # pragma: no cover |
| 642 # Print stderr for debugging. | 656 # Print stderr for debugging. |
| 643 print title % "Stderr" | 657 print title % "Stderr" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 help="Path to a file for storing json results from run " | 829 help="Path to a file for storing json results from run " |
| 816 "without patch.") | 830 "without patch.") |
| 817 parser.add_option("--outdir", help="Base directory with compile output", | 831 parser.add_option("--outdir", help="Base directory with compile output", |
| 818 default="out") | 832 default="out") |
| 819 parser.add_option("--outdir-no-patch", | 833 parser.add_option("--outdir-no-patch", |
| 820 help="Base directory with compile output without patch") | 834 help="Base directory with compile output without patch") |
| 821 parser.add_option("--binary-override-path", | 835 parser.add_option("--binary-override-path", |
| 822 help="JavaScript engine binary. By default, d8 under " | 836 help="JavaScript engine binary. By default, d8 under " |
| 823 "architecture-specific build dir. " | 837 "architecture-specific build dir. " |
| 824 "Not supported in conjunction with outdir-no-patch.") | 838 "Not supported in conjunction with outdir-no-patch.") |
| 839 parser.add_option("--prioritize", | |
| 840 help="Raise the priority to nice -20 for the benchmarking pr ocess." | |
| 841 "Requires Linux, schedtool, and sudo privileges.", | |
| 842 default=False, action="store_true") | |
| 843 parser.add_option("--affinitize", | |
| 844 help="Run benchmarking process on the specified core." | |
| 845 "Requires Linux, schedtool, and sudo privileges.", | |
| 846 default=None) | |
| 825 | 847 |
| 826 (options, args) = parser.parse_args(args) | 848 (options, args) = parser.parse_args(args) |
| 827 | 849 |
| 828 if len(args) == 0: # pragma: no cover | 850 if len(args) == 0: # pragma: no cover |
| 829 parser.print_help() | 851 parser.print_help() |
| 830 return 1 | 852 return 1 |
| 831 | 853 |
| 832 if options.arch in ["auto", "native"]: # pragma: no cover | 854 if options.arch in ["auto", "native"]: # pragma: no cover |
| 833 options.arch = ARCH_GUESS | 855 options.arch = ARCH_GUESS |
| 834 | 856 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 | 947 |
| 926 if options.json_test_results_no_patch: | 948 if options.json_test_results_no_patch: |
| 927 results_no_patch.WriteToFile(options.json_test_results_no_patch) | 949 results_no_patch.WriteToFile(options.json_test_results_no_patch) |
| 928 else: # pragma: no cover | 950 else: # pragma: no cover |
| 929 print results_no_patch | 951 print results_no_patch |
| 930 | 952 |
| 931 return min(1, len(results.errors)) | 953 return min(1, len(results.errors)) |
| 932 | 954 |
| 933 if __name__ == "__main__": # pragma: no cover | 955 if __name__ == "__main__": # pragma: no cover |
| 934 sys.exit(Main(sys.argv[1:])) | 956 sys.exit(Main(sys.argv[1:])) |
| OLD | NEW |