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

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

Issue 1255673002: [Android][Telemetry] Add support for multiple power monitors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | tools/telemetry/telemetry/internal/platform/android_platform_backend.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 telemetry.util import process_statistic_timeline_data 7 from telemetry.util import process_statistic_timeline_data
8 from telemetry.value import scalar 8 from telemetry.value import scalar
9 9
10 from metrics import Metric 10 from metrics import Metric
11 11
12 12
13 MONSOON_POWER_LABEL = 'monsoon_energy_consumption_mwh'
14 FUELGAUGE_POWER_LABEL = 'fuel_gauge_energy_consumption_mwh'
15 APP_POWER_LABEL = 'application_energy_consumption_mwh'
16 TOTAL_POWER_LABEL = 'energy_consumption_mwh'
17
13 class PowerMetric(Metric): 18 class PowerMetric(Metric):
14 """A metric for measuring power usage.""" 19 """A metric for measuring power usage."""
15 20
16 # System power draw while idle. 21 # System power draw while idle.
17 _quiescent_power_draw_mwh = 0 22 _quiescent_power_draw_mwh = 0
18 23
19 def __init__(self, platform, quiescent_measurement_time_s=0): 24 def __init__(self, platform, quiescent_measurement_time_s=0):
20 """PowerMetric Constructor. 25 """PowerMetric Constructor.
21 26
22 Args: 27 Args:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return 63 return
59 64
60 # Only perform quiescent measurement once per run. 65 # Only perform quiescent measurement once per run.
61 if PowerMetric._quiescent_power_draw_mwh: 66 if PowerMetric._quiescent_power_draw_mwh:
62 return 67 return
63 68
64 self._platform.StartMonitoringPower(self._browser) 69 self._platform.StartMonitoringPower(self._browser)
65 time.sleep(measurement_time_s) 70 time.sleep(measurement_time_s)
66 power_results = self._platform.StopMonitoringPower() 71 power_results = self._platform.StopMonitoringPower()
67 PowerMetric._quiescent_power_draw_mwh = ( 72 PowerMetric._quiescent_power_draw_mwh = (
68 power_results.get('energy_consumption_mwh', 0)) 73 power_results.get(TOTAL_POWER_LABEL, 0))
69 74
70 def Start(self, _, tab): 75 def Start(self, _, tab):
71 self._browser = tab.browser 76 self._browser = tab.browser
72 77
73 if not self._platform.CanMonitorPower(): 78 if not self._platform.CanMonitorPower():
74 return 79 return
75 80
76 self._results = None 81 self._results = None
77 self._StopInternal() 82 self._StopInternal()
78 83
(...skipping 13 matching lines...) Expand all
92 97
93 This function needs to be robust in the face of differing power data on 98 This function needs to be robust in the face of differing power data on
94 various platforms. Therefore data existence needs to be checked when 99 various platforms. Therefore data existence needs to be checked when
95 building up the results. Additionally 0 is a valid value for many of the 100 building up the results. Additionally 0 is a valid value for many of the
96 metrics here which is why there are plenty of checks for 'is not None' 101 metrics here which is why there are plenty of checks for 'is not None'
97 below. 102 below.
98 """ 103 """
99 if not self._results: 104 if not self._results:
100 return 105 return
101 106
102 application_energy_consumption_mwh = ( 107 application_energy_consumption_mwh = self._results.get(APP_POWER_LABEL)
103 self._results.get('application_energy_consumption_mwh')) 108 total_energy_consumption_mwh = self._results.get(TOTAL_POWER_LABEL)
104 total_energy_consumption_mwh = self._results.get('energy_consumption_mwh') 109 fuel_gauge_energy_consumption_mwh = self._results.get(FUELGAUGE_POWER_LABEL)
105 fuel_gauge_energy_consumption_mwh = ( 110 monsoon_energy_consumption_mwh = self._results.get(MONSOON_POWER_LABEL)
106 self._results.get('fuel_gauge_energy_consumption_mwh'))
107 111
108 if (PowerMetric._quiescent_power_draw_mwh and 112 if (PowerMetric._quiescent_power_draw_mwh and
109 application_energy_consumption_mwh is None and 113 application_energy_consumption_mwh is None and
110 total_energy_consumption_mwh is not None): 114 total_energy_consumption_mwh is not None):
111 application_energy_consumption_mwh = max( 115 application_energy_consumption_mwh = max(
112 total_energy_consumption_mwh - PowerMetric._quiescent_power_draw_mwh, 116 total_energy_consumption_mwh - PowerMetric._quiescent_power_draw_mwh,
113 0) 117 0)
114 118
115 if fuel_gauge_energy_consumption_mwh is not None: 119 if fuel_gauge_energy_consumption_mwh is not None:
116 results.AddValue(scalar.ScalarValue( 120 results.AddValue(scalar.ScalarValue(
117 results.current_page, 'fuel_gauge_energy_consumption_mwh', 'mWh', 121 results.current_page, FUELGAUGE_POWER_LABEL, 'mWh',
118 fuel_gauge_energy_consumption_mwh)) 122 fuel_gauge_energy_consumption_mwh))
119 123
124 if monsoon_energy_consumption_mwh is not None:
125 results.AddValue(scalar.ScalarValue(
126 results.current_page, MONSOON_POWER_LABEL, 'mWh',
127 monsoon_energy_consumption_mwh))
128
120 if total_energy_consumption_mwh is not None: 129 if total_energy_consumption_mwh is not None:
121 results.AddValue(scalar.ScalarValue( 130 results.AddValue(scalar.ScalarValue(
122 results.current_page, 'energy_consumption_mwh', 'mWh', 131 results.current_page, TOTAL_POWER_LABEL, 'mWh',
123 total_energy_consumption_mwh)) 132 total_energy_consumption_mwh))
124 133
125 if application_energy_consumption_mwh is not None: 134 if application_energy_consumption_mwh is not None:
126 results.AddValue(scalar.ScalarValue( 135 results.AddValue(scalar.ScalarValue(
127 results.current_page, 'application_energy_consumption_mwh', 'mWh', 136 results.current_page, APP_POWER_LABEL, 'mWh',
128 application_energy_consumption_mwh)) 137 application_energy_consumption_mwh))
129 138
130 component_utilization = self._results.get('component_utilization', {}) 139 component_utilization = self._results.get('component_utilization', {})
131 # GPU Frequency. 140 # GPU Frequency.
132 gpu_power = component_utilization.get('gpu', {}) 141 gpu_power = component_utilization.get('gpu', {})
133 gpu_freq_hz = gpu_power.get('average_frequency_hz') 142 gpu_freq_hz = gpu_power.get('average_frequency_hz')
134 if gpu_freq_hz is not None: 143 if gpu_freq_hz is not None:
135 results.AddValue(scalar.ScalarValue( 144 results.AddValue(scalar.ScalarValue(
136 results.current_page, 'gpu_average_frequency_hz', 'hz', gpu_freq_hz, 145 results.current_page, 'gpu_average_frequency_hz', 'hz', gpu_freq_hz,
137 important=False)) 146 important=False))
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 continue 203 continue
195 204
196 assert isinstance(cpu_stats[process_type]['IdleWakeupCount'], 205 assert isinstance(cpu_stats[process_type]['IdleWakeupCount'],
197 process_statistic_timeline_data.IdleWakeupTimelineData) 206 process_statistic_timeline_data.IdleWakeupTimelineData)
198 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] - 207 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] -
199 start_cpu_stats[process_type]['IdleWakeupCount']) 208 start_cpu_stats[process_type]['IdleWakeupCount'])
200 cpu_delta[process_type] = idle_wakeup_delta.total_sum() 209 cpu_delta[process_type] = idle_wakeup_delta.total_sum()
201 total = total + cpu_delta[process_type] 210 total = total + cpu_delta[process_type]
202 cpu_delta['Total'] = total 211 cpu_delta['Total'] = total
203 return cpu_delta 212 return cpu_delta
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/internal/platform/android_platform_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698