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

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: unit-info 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..159913efca0424f3d517d4414c777ad71d7f2b58 100644
--- a/tools/perf/metrics/cpu.py
+++ b/tools/perf/metrics/cpu.py
@@ -30,10 +30,25 @@ 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: these are system-wide metrics,
+ # not per process as the ones above.
+ total_time = 0.0
+ frequency_sum = 0.0
+ for frequency, time_in_state in \
+ self._results['Global']['GlobalCpuFrequencyStats'].iteritems():
+ frequency_sum += (frequency * time_in_state)
+ total_time += time_in_state
+ if total_time:
+ results.Add('average_frequency_mhz', 'MHz',
+ round((frequency_sum / total_time) / 1000.0, 2),
qyearsley 2014/04/23 18:38:22 If the frequency numbers are in Hz, then should we
bulach 2014/05/06 17:08:19 I suppose /proc is in KHz?
qyearsley 2014/05/06 17:42:28 Might be good to add a link to some reference that
+ chart_name='cpu_frequency',
+ data_type='unimportant')
def _SubtractCpuStats(cpu_stats, start_cpu_stats):
@@ -56,7 +71,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.
pasko 2014/05/07 17:59:27 s/empty/empty or global/ ?
bulach 2014/05/08 12:38:02 Done.
- 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 +81,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