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

Side by Side Diff: tools/perf/metrics/cpu.py

Issue 1092393002: Telemetry: Quiescent power benchmarks for Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@safari-backend
Patch Set: Fix missing idle_wakeups_renderer Created 5 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 unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from telemetry.value import scalar 5 from telemetry.value import scalar
6 6
7 from metrics import Metric 7 from metrics import Metric
8 8
9 9
10 class CpuMetric(Metric): 10 class CpuMetric(Metric):
(...skipping 14 matching lines...) Expand all
25 25
26 def Stop(self, page, tab): 26 def Stop(self, page, tab):
27 assert self._start_cpu, 'Must call Start() first' 27 assert self._start_cpu, 'Must call Start() first'
28 self._stop_cpu = self._browser.cpu_stats 28 self._stop_cpu = self._browser.cpu_stats
29 29
30 # Optional argument trace_name is not in base class Metric. 30 # Optional argument trace_name is not in base class Metric.
31 # pylint: disable=W0221 31 # pylint: disable=W0221
32 def AddResults(self, tab, results, trace_name='cpu_utilization'): 32 def AddResults(self, tab, results, trace_name='cpu_utilization'):
33 assert self._stop_cpu, 'Must call Stop() first' 33 assert self._stop_cpu, 'Must call Stop() first'
34 cpu_stats = _SubtractCpuStats(self._stop_cpu, self._start_cpu) 34 cpu_stats = _SubtractCpuStats(self._stop_cpu, self._start_cpu)
35
36 # FIXME: Renderer process CPU times are impossible to compare correctly.
37 # http://crbug.com/419786#c11
38 if 'Renderer' in cpu_stats:
39 del cpu_stats['Renderer']
40
35 # Add a result for each process type. 41 # Add a result for each process type.
36 for process_type in cpu_stats: 42 for process_type in cpu_stats:
37 trace_name_for_process = '%s_%s' % (trace_name, process_type.lower()) 43 trace_name_for_process = '%s_%s' % (trace_name, process_type.lower())
38 cpu_percent = 100 * cpu_stats[process_type] 44 cpu_percent = 100 * cpu_stats[process_type]
39 results.AddValue(scalar.ScalarValue( 45 results.AddValue(scalar.ScalarValue(
40 results.current_page, 'cpu_utilization.%s' % trace_name_for_process, 46 results.current_page, 'cpu_utilization.%s' % trace_name_for_process,
41 '%', cpu_percent, important=False)) 47 '%', cpu_percent, important=False))
42 48
43 49
44 def _SubtractCpuStats(cpu_stats, start_cpu_stats): 50 def _SubtractCpuStats(cpu_stats, start_cpu_stats):
(...skipping 26 matching lines...) Expand all
71 # Linux kernel starts with a value close to an overflow, so correction is 77 # Linux kernel starts with a value close to an overflow, so correction is
72 # necessary. 78 # necessary.
73 if total_time < 0: 79 if total_time < 0:
74 total_time += 2**32 80 total_time += 2**32
75 # Assert that the arguments were given in the correct order. 81 # Assert that the arguments were given in the correct order.
76 assert total_time > 0 and total_time < 2**31, ( 82 assert total_time > 0 and total_time < 2**31, (
77 'Expected total_time > 0, was: %d' % total_time) 83 'Expected total_time > 0, was: %d' % total_time)
78 cpu_usage[process_type] = float(cpu_process_time) / total_time 84 cpu_usage[process_type] = float(cpu_process_time) / total_time
79 return cpu_usage 85 return cpu_usage
80 86
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698