Chromium Code Reviews| Index: telemetry/telemetry/internal/platform/tracing_agent/cpu_tracing_agent.py |
| diff --git a/telemetry/telemetry/internal/platform/tracing_agent/cpu_tracing_agent.py b/telemetry/telemetry/internal/platform/tracing_agent/cpu_tracing_agent.py |
| index 44cc1b10c9e58047ed54086e0f28553ac4ba15b6..5deaf2966ff42591a4882833e4d69ca3eed2f848 100644 |
| --- a/telemetry/telemetry/internal/platform/tracing_agent/cpu_tracing_agent.py |
| +++ b/telemetry/telemetry/internal/platform/tracing_agent/cpu_tracing_agent.py |
| @@ -35,7 +35,7 @@ class UnixProcessCollector(ProcessCollector): |
| 'pCpu': 2, |
| 'pid': 0, |
| 'pMem': 3, |
| - 'path': 1 |
| + 'command': 1 |
| } |
| def __init__(self, min_pcpu, binary_output=False): |
| @@ -75,7 +75,6 @@ class UnixProcessCollector(ProcessCollector): |
| process = self._ParseLine(process_line) |
| if (not process) or (float(process['pCpu']) < self._min_pcpu): |
| continue |
| - process['name'] = os.path.split(process['path'])[1] |
| top_processes.append(process) |
| return top_processes |
| @@ -107,7 +106,7 @@ class WindowsProcessCollector(ProcessCollector): |
| 'pMem': p.get_memory_percent(), |
| 'name': p.name, |
| 'pid': p.pid, |
| - 'path': path |
| + 'command': path |
| }) |
| except psutil.Error: |
| logging.exception('Failed to get process data') |
| @@ -121,7 +120,7 @@ class LinuxProcessCollector(UnixProcessCollector): |
| Example of Linux command output: '31887 com.app.Webkit 3.4 8.0'""" |
| - _SHELL_COMMAND = ["ps", "axo", "pid,cmd,pcpu,pmem", "--sort=-pcpu"] |
| + _SHELL_COMMAND = ["es", "axo", "pid,cmd,pcpu,pmem", "--sort=-pcpu"] |
| def __init__(self, min_pcpu): |
| @@ -134,11 +133,30 @@ class MacProcessCollector(UnixProcessCollector): |
| Example of Mac command output: |
| '31887 com.app.Webkit 3.4 8.0'""" |
| - _SHELL_COMMAND = ['ps', '-arcwwwxo', 'pid command %cpu %mem'] |
| + _SHELL_COMMAND = ['ps', |
| + '-r', # Sort by CPU usage. |
| + '-A', # Display info about all other processes. |
| + '-www', # Use as much column as needed. |
| + '-x', # Include processes which do not have controlling |
| + # terminal |
| + '-o', 'pid %cpu %mem command'] |
|
nednguyen
2016/09/13 12:46:22
The trick is to rearrange the output columns so th
|
| def __init__(self, min_pcpu): |
| super(MacProcessCollector, self).__init__(min_pcpu, binary_output=True) |
| + def _ParseLine(self, line): |
| + token_list = line.strip().split() |
| + if not token_list: |
| + return None |
| + pid, pCpu, pMem = token_list[0], token_list[1], token_list[2] |
| + cmd = ' '.join(token_list[3:]) |
| + return { |
| + 'pid': pid, |
| + 'pCpu': pCpu, |
| + 'pMem': pMem, |
| + 'command': cmd |
|
nednguyen
2016/09/13 12:46:22
full command is more useful than name
|
| + } |
| + |
| class CpuTracingAgent(tracing_agent.TracingAgent): |