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 process_statistic_timeline_data | 8 from telemetry.core.platform import process_statistic_timeline_data |
9 from telemetry.value import scalar | 9 from telemetry.value import scalar |
10 | 10 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 """Computes number of idle wakeups that occurred over measurement period. | 163 """Computes number of idle wakeups that occurred over measurement period. |
164 | 164 |
165 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 |
166 Browser.cpu_stats call. | 166 Browser.cpu_stats call. |
167 | 167 |
168 Returns: | 168 Returns: |
169 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 |
170 over the period recorded by the input. | 170 over the period recorded by the input. |
171 """ | 171 """ |
172 cpu_delta = {} | 172 cpu_delta = {} |
| 173 total = 0 |
173 for process_type in cpu_stats: | 174 for process_type in cpu_stats: |
174 assert process_type in start_cpu_stats, 'Mismatching process types' | 175 assert process_type in start_cpu_stats, 'Mismatching process types' |
175 # Skip any process_types that are empty. | 176 # Skip any process_types that are empty. |
176 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]): | 177 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]): |
177 continue | 178 continue |
178 # Skip if IdleWakeupCount is not present. | 179 # Skip if IdleWakeupCount is not present. |
179 if (('IdleWakeupCount' not in cpu_stats[process_type]) or | 180 if (('IdleWakeupCount' not in cpu_stats[process_type]) or |
180 ('IdleWakeupCount' not in start_cpu_stats[process_type])): | 181 ('IdleWakeupCount' not in start_cpu_stats[process_type])): |
181 continue | 182 continue |
182 | 183 |
183 assert isinstance(cpu_stats[process_type]['IdleWakeupCount'], | 184 assert isinstance(cpu_stats[process_type]['IdleWakeupCount'], |
184 process_statistic_timeline_data.IdleWakeupTimelineData) | 185 process_statistic_timeline_data.IdleWakeupTimelineData) |
185 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] - | 186 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] - |
186 start_cpu_stats[process_type]['IdleWakeupCount']) | 187 start_cpu_stats[process_type]['IdleWakeupCount']) |
187 cpu_delta[process_type] = idle_wakeup_delta.total_sum() | 188 cpu_delta[process_type] = idle_wakeup_delta.total_sum() |
| 189 total = total + cpu_delta[process_type] |
| 190 cpu_delta['Total'] = total |
188 return cpu_delta | 191 return cpu_delta |
OLD | NEW |