| 906 | |
| 907 | |
| 908 | class DesktopPlatform(Platform): |
| 909 | def __init__(self, args): |
| 910 | super(DesktopPlatform, self).__init__(args) |
| 911 | self.command_prefix = [] |
| 912 | |
| 913 | # Setup command class to OS specific version. |
| 914 | command.setup(utils.GuessOS(), args.device) |
| 915 | |
| 916 | if args.prioritize or args.affinitize is not None: |
| 917 | self.command_prefix = ['schedtool'] |
| 918 | if args.prioritize: |
| 919 | self.command_prefix += ['-n', '-20'] |
| 920 | if args.affinitize is not None: |
| 921 | # schedtool expects a bit pattern when setting affinity, where each |
| 922 | # bit set to '1' corresponds to a core where the process may run on. |
| 923 | # First bit corresponds to CPU 0. Since the 'affinitize' parameter is |
| 924 | # a core number, we need to map to said bit pattern. |
| 925 | cpu = int(args.affinitize) |
| 926 | core = 1 << cpu |
| 927 | self.command_prefix += ['-a', ('0x%x' % core)] |
| 928 | self.command_prefix += ['-e'] |
| 929 | |
| 930 | if args.checked_warmup: |
| 931 | self.warmup_manager = CachedWarmupManager() |
| 932 | |
| 933 | def PreExecution(self): |
| 934 | pass |
| 935 | |
| 936 | def PostExecution(self): |
| 937 | pass |
| 938 | |
| 939 | def PreTests(self, node, path): |
| 940 | if isinstance(node, RunnableConfig): |
| 941 | node.ChangeCWD(path) |
| 942 | |
| 943 | def _Run(self, runnable, count, secondary=False, post_process=True): |
| 944 | shell_dir = self.shell_dir_secondary if secondary else self.shell_dir |
| 945 | cmd = runnable.GetCommand(self.command_prefix, shell_dir, self.extra_flags) |
| 946 | logging.debug('Running command: %s' % cmd) |
| 947 | output = Output() if self.is_dry_run else cmd.execute() |
| 948 | |
| 949 | if (not self.is_dry_run and |
| 950 | post_process and |
| 951 | output.IsSuccess() and |
| 952 | '--prof' in self.extra_flags): |
| 953 | os_prefix = {'linux': 'linux', 'macos': 'mac'}.get(utils.GuessOS()) |
| 954 | if os_prefix: |
| 955 | tick_tools = os.path.join(TOOLS_BASE, '%s-tick-processor' % os_prefix) |
| 956 | subprocess.check_call(tick_tools + ' --only-summary', shell=True) |
| 957 | else: # pragma: no cover |
| 958 | logging.warning( |
| 959 | 'Profiler option currently supported on Linux and Mac OS.') |
| 960 | |
| 961 | # /usr/bin/time outputs to stderr |
| 962 | if runnable.process_size: |
| 963 | output.stdout += output.stderr |
| 964 | return output |
| 965 |
no outgoing calls
no test coverage detected
searching dependent graphs…