Chromium Code Reviews| Index: tools/perf/metrics/cpu.py |
| diff --git a/tools/perf/metrics/cpu.py b/tools/perf/metrics/cpu.py |
| index aa57b073078a791ea945e954f030c1c3cf9b3d9a..d5ee98f6b9463c3ae0d65d7967fa0bb2c0488104 100644 |
| --- a/tools/perf/metrics/cpu.py |
| +++ b/tools/perf/metrics/cpu.py |
| @@ -30,10 +30,22 @@ class CpuMetric(Metric): |
| assert self._results, 'Must call Stop() first' |
| # Add a result for each process type. |
| for process_type in self._results: |
| + if process_type == 'Global': |
| + continue |
| trace_name_for_process = '%s_%s' % (trace_name, process_type.lower()) |
| cpu_percent = 100 * self._results[process_type] |
| results.Add(trace_name_for_process, '%', cpu_percent, |
| chart_name='cpu_utilization', data_type='unimportant') |
| + # Add a result for Global CPU stats. |
|
qyearsley
2014/04/22 17:00:51
Does "Global" mean all process types combined?
bulach
2014/04/22 17:12:30
sort of. :)
it means system-wide utilization, not
qyearsley
2014/04/22 17:25:52
Alright -- not sure if it would be clearer if you
bulach
2014/04/22 17:52:48
Done.
|
| + time_spent = 0.0 |
|
qyearsley
2014/04/22 17:00:51
Is this in seconds or milliseconds?
bulach
2014/04/22 17:12:30
I suppose the unit is 10mS:
https://www.kernel.org
|
| + frequency_sum = 0.0 |
| + for k, v in self._results['Global']['GlobalCpuFrequencyStats'].iteritems(): |
| + frequency_sum += (k * v) |
|
qyearsley
2014/04/22 17:00:51
So what does frequency_sum represent? What are k a
bulach
2014/04/22 17:12:30
k and v are the key-values, happy to expand to fre
qyearsley
2014/04/22 17:25:52
I think it would be a bit clearer if it were frequ
bulach
2014/04/22 17:52:48
Replaced k, v with frequency, time_in_state.
I cou
|
| + time_spent += v |
| + results.Add('average_frequency_hz', 'Hz', |
| + int(frequency_sum / time_spent), |
| + chart_name='cpu_frequency', |
| + data_type='unimportant') |
|
pasko
2014/04/22 14:06:30
what does data_type mean? is it documented anywher
qyearsley
2014/04/22 17:00:51
The data_type parameter specifies two things -- wh
|
| def _SubtractCpuStats(cpu_stats, start_cpu_stats): |
| @@ -56,7 +68,9 @@ def _SubtractCpuStats(cpu_stats, start_cpu_stats): |
| for process_type in cpu_stats: |
| assert process_type in start_cpu_stats, 'Mismatching process types' |
| # Skip any process_types that are empty. |
| - if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]): |
| + if ((not cpu_stats[process_type]) or |
| + (not start_cpu_stats[process_type]) or |
| + process_type == 'Global'): |
| continue |
| cpu_process_time = (cpu_stats[process_type]['CpuProcessTime'] - |
| start_cpu_stats[process_type]['CpuProcessTime']) |
| @@ -64,5 +78,16 @@ def _SubtractCpuStats(cpu_stats, start_cpu_stats): |
| start_cpu_stats[process_type]['TotalTime']) |
| assert total_time > 0, 'Expected total_time > 0, was: %d' % total_time |
| cpu_usage[process_type] = float(cpu_process_time) / total_time |
| - return cpu_usage |
| + if 'Global' not in cpu_stats: |
| + return cpu_usage |
| + |
| + frequency_stats = cpu_stats['Global']['GlobalCpuFrequencyStats'] |
| + start_frequency_stats = start_cpu_stats['Global']['GlobalCpuFrequencyStats'] |
| + total_frequency_stats = {} |
| + for k in frequency_stats.iterkeys(): |
| + total_frequency_stats[k] = frequency_stats[k] - start_frequency_stats[k] |
| + |
| + cpu_usage['Global'] = {} |
| + cpu_usage['Global']['GlobalCpuFrequencyStats'] = total_frequency_stats |
| + return cpu_usage |