Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: tools/perf/metrics/cpu.py

Issue 239083010: Telemetry: adds CPU frequency stats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/perf/metrics/cpu.py
diff --git a/tools/perf/metrics/cpu.py b/tools/perf/metrics/cpu.py
index aa57b073078a791ea945e954f030c1c3cf9b3d9a..cb316ec32cfa1bc60a64069e1407d5a29fd05003 100644
--- a/tools/perf/metrics/cpu.py
+++ b/tools/perf/metrics/cpu.py
@@ -30,10 +30,16 @@ 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.
+ for k, v in self._results['Global']['GlobalCpuFrequencyStats'].iteritems():
+ results.Add(k, 'ms', v,
tonyg 2014/04/18 03:58:56 I think this needs to either be a histogram result
bulach 2014/04/22 12:43:10 ouch, indeed.... averaging it out as average_frequ
+ chart_name='cpu_freq', data_type='unimportant')
def _SubtractCpuStats(cpu_stats, start_cpu_stats):
@@ -56,7 +62,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 +72,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

Powered by Google App Engine
This is Rietveld 408576698