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.value import scalar | 8 from telemetry.value import scalar |
9 | 9 |
10 | 10 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 important=False)) | 131 important=False)) |
132 | 132 |
133 # Add temperature measurements. | 133 # Add temperature measurements. |
134 whole_package_utilization = component_utilization.get('whole_package', {}) | 134 whole_package_utilization = component_utilization.get('whole_package', {}) |
135 board_temperature_c = whole_package_utilization.get('average_temperature_c') | 135 board_temperature_c = whole_package_utilization.get('average_temperature_c') |
136 if board_temperature_c is not None: | 136 if board_temperature_c is not None: |
137 results.AddValue(scalar.ScalarValue( | 137 results.AddValue(scalar.ScalarValue( |
138 results.current_page, 'board_temperature', 'celsius', | 138 results.current_page, 'board_temperature', 'celsius', |
139 board_temperature_c, important=False)) | 139 board_temperature_c, important=False)) |
140 | 140 |
| 141 # Add CPU frequency measurements. |
| 142 frequency_hz = whole_package_utilization.get('frequency_percent') |
| 143 if frequency_hz is not None: |
| 144 frequency_sum = 0.0 |
| 145 for freq, percent in frequency_hz.iteritems(): |
| 146 frequency_sum += freq * (percent / 100.0) |
| 147 results.AddValue(scalar.ScalarValue( |
| 148 results.current_page, 'cpu_average_frequency_hz', 'Hz', |
| 149 frequency_sum, important=False)) |
| 150 |
| 151 # Add CPU c-state residency measurements. |
| 152 cstate_percent = whole_package_utilization.get('cstate_residency_percent') |
| 153 if cstate_percent is not None: |
| 154 for state, percent in cstate_percent.iteritems(): |
| 155 results.AddValue(scalar.ScalarValue( |
| 156 results.current_page, 'cpu_cstate_%s_residency_percent' % state, |
| 157 '%', percent, important=False)) |
| 158 |
141 self._results = None | 159 self._results = None |
142 | 160 |
143 def _SubtractCpuStats(cpu_stats, start_cpu_stats): | 161 def _SubtractCpuStats(cpu_stats, start_cpu_stats): |
144 """Computes number of idle wakeups that occurred over measurement period. | 162 """Computes number of idle wakeups that occurred over measurement period. |
145 | 163 |
146 Each of the two cpu_stats arguments is a dict as returned by the | 164 Each of the two cpu_stats arguments is a dict as returned by the |
147 Browser.cpu_stats call. | 165 Browser.cpu_stats call. |
148 | 166 |
149 Returns: | 167 Returns: |
150 A dict of process type names (Browser, Renderer, etc.) to idle wakeup count | 168 A dict of process type names (Browser, Renderer, etc.) to idle wakeup count |
151 over the period recorded by the input. | 169 over the period recorded by the input. |
152 """ | 170 """ |
153 cpu_delta = {} | 171 cpu_delta = {} |
154 for process_type in cpu_stats: | 172 for process_type in cpu_stats: |
155 assert process_type in start_cpu_stats, 'Mismatching process types' | 173 assert process_type in start_cpu_stats, 'Mismatching process types' |
156 # Skip any process_types that are empty. | 174 # Skip any process_types that are empty. |
157 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]): | 175 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]): |
158 continue | 176 continue |
159 # Skip if IdleWakeupCount is not present. | 177 # Skip if IdleWakeupCount is not present. |
160 if (('IdleWakeupCount' not in cpu_stats[process_type]) or | 178 if (('IdleWakeupCount' not in cpu_stats[process_type]) or |
161 ('IdleWakeupCount' not in start_cpu_stats[process_type])): | 179 ('IdleWakeupCount' not in start_cpu_stats[process_type])): |
162 continue | 180 continue |
163 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] - | 181 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] - |
164 start_cpu_stats[process_type]['IdleWakeupCount']) | 182 start_cpu_stats[process_type]['IdleWakeupCount']) |
165 cpu_delta[process_type] = idle_wakeup_delta | 183 cpu_delta[process_type] = idle_wakeup_delta |
166 return cpu_delta | 184 return cpu_delta |
OLD | NEW |