OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import time | 5 import time |
6 | 6 |
7 from metrics import Metric | 7 from metrics import Metric |
8 from telemetry.core.platform import timeline_objects | |
8 from telemetry.value import scalar | 9 from telemetry.value import scalar |
9 | 10 |
10 | 11 |
11 class PowerMetric(Metric): | 12 class PowerMetric(Metric): |
12 """A metric for measuring power usage.""" | 13 """A metric for measuring power usage.""" |
13 | 14 |
14 # System power draw while idle. | 15 # System power draw while idle. |
15 _quiescent_power_draw_mwh = 0 | 16 _quiescent_power_draw_mwh = 0 |
16 | 17 |
17 def __init__(self, browser, quiescent_measurement_time_s=0): | 18 def __init__(self, browser, quiescent_measurement_time_s=0): |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 # Add CPU c-state residency measurements. | 152 # Add CPU c-state residency measurements. |
152 cstate_percent = whole_package_utilization.get('cstate_residency_percent') | 153 cstate_percent = whole_package_utilization.get('cstate_residency_percent') |
153 if cstate_percent is not None: | 154 if cstate_percent is not None: |
154 for state, percent in cstate_percent.iteritems(): | 155 for state, percent in cstate_percent.iteritems(): |
155 results.AddValue(scalar.ScalarValue( | 156 results.AddValue(scalar.ScalarValue( |
156 results.current_page, 'cpu_cstate_%s_residency_percent' % state, | 157 results.current_page, 'cpu_cstate_%s_residency_percent' % state, |
157 '%', percent, important=False)) | 158 '%', percent, important=False)) |
158 | 159 |
159 self._results = None | 160 self._results = None |
160 | 161 |
161 def _SubtractCpuStats(cpu_stats, start_cpu_stats): | 162 def _SubtractCpuStats(cpu_stats, start_cpu_stats): |
tonyg
2014/08/24 16:53:43
I was hoping this whole method would go away from
| |
162 """Computes number of idle wakeups that occurred over measurement period. | 163 """Computes number of idle wakeups that occurred over measurement period. |
163 | 164 |
164 Each of the two cpu_stats arguments is a dict as returned by the | 165 Each of the two cpu_stats arguments is a dict as returned by the |
165 Browser.cpu_stats call. | 166 Browser.cpu_stats call. |
166 | 167 |
167 Returns: | 168 Returns: |
168 A dict of process type names (Browser, Renderer, etc.) to idle wakeup count | 169 A dict of process type names (Browser, Renderer, etc.) to idle wakeup count |
169 over the period recorded by the input. | 170 over the period recorded by the input. |
170 """ | 171 """ |
171 cpu_delta = {} | 172 cpu_delta = {} |
172 for process_type in cpu_stats: | 173 for process_type in cpu_stats: |
173 assert process_type in start_cpu_stats, 'Mismatching process types' | 174 assert process_type in start_cpu_stats, 'Mismatching process types' |
174 # Skip any process_types that are empty. | 175 # Skip any process_types that are empty. |
175 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]): | 176 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]): |
176 continue | 177 continue |
177 # Skip if IdleWakeupCount is not present. | 178 # Skip if IdleWakeupCount is not present. |
178 if (('IdleWakeupCount' not in cpu_stats[process_type]) or | 179 if (('IdleWakeupCount' not in cpu_stats[process_type]) or |
179 ('IdleWakeupCount' not in start_cpu_stats[process_type])): | 180 ('IdleWakeupCount' not in start_cpu_stats[process_type])): |
180 continue | 181 continue |
182 | |
183 # Verify that the IdleWakeupCount field has been converted to a | |
tonyg
2014/08/24 16:53:43
Let's just kill this comment. It answers "what" in
jeremy
2014/08/26 14:14:16
Done.
| |
184 # TimlineData-based object. | |
185 assert isinstance(cpu_stats[process_type]['IdleWakeupCount'], | |
186 timeline_objects.IdleStatsData) | |
181 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] - | 187 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] - |
182 start_cpu_stats[process_type]['IdleWakeupCount']) | 188 start_cpu_stats[process_type]['IdleWakeupCount']) |
183 cpu_delta[process_type] = idle_wakeup_delta | 189 cpu_delta[process_type] = idle_wakeup_delta.IdleWakeupCount() |
184 return cpu_delta | 190 return cpu_delta |
OLD | NEW |