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

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

Issue 451523004: [Telemetry] Fix cpu metric on non-rooted devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/metrics/cpu.py
diff --git a/tools/perf/metrics/cpu.py b/tools/perf/metrics/cpu.py
index 3d54a9040efca5586db0fdc4c488976a79c824b9..d0a03040f439246b258fa6ac3cb98c180d49f79b 100644
--- a/tools/perf/metrics/cpu.py
+++ b/tools/perf/metrics/cpu.py
@@ -11,9 +11,9 @@ class CpuMetric(Metric):
def __init__(self, browser):
super(CpuMetric, self).__init__()
- self._results = None
self._browser = browser
self._start_cpu = None
+ self._stop_cpu = None
def DidStartBrowser(self, browser):
# Save the browser object so that cpu_stats can be accessed later.
@@ -24,16 +24,17 @@ class CpuMetric(Metric):
def Stop(self, page, tab):
assert self._start_cpu, 'Must call Start() first'
- self._results = _SubtractCpuStats(self._browser.cpu_stats, self._start_cpu)
+ self._stop_cpu = self._browser.cpu_stats
# Optional argument trace_name is not in base class Metric.
# pylint: disable=W0221
def AddResults(self, tab, results, trace_name='cpu_utilization'):
- assert self._results, 'Must call Stop() first'
+ assert self._stop_cpu, 'Must call Stop() first'
+ cpu_stats = _SubtractCpuStats(self._stop_cpu, self._start_cpu)
# Add a result for each process type.
- for process_type in self._results:
+ for process_type in cpu_stats:
trace_name_for_process = '%s_%s' % (trace_name, process_type.lower())
- cpu_percent = 100 * self._results[process_type]
+ cpu_percent = 100 * cpu_stats[process_type]
results.AddValue(scalar.ScalarValue(
results.current_page, 'cpu_utilization.%s' % trace_name_for_process,
'%', cpu_percent, important=False))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698