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

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

Issue 230163004: Using decorator for power monitoring. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 logging 5 import logging
6 6
7 from metrics import Metric 7 from metrics import Metric
8 from telemetry.core.platform import factory 8 from telemetry.core.platform import factory
9 9
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 def Stop(self, _, tab): 73 def Stop(self, _, tab):
74 if not PowerMetric.enabled: 74 if not PowerMetric.enabled:
75 return 75 return
76 76
77 if not tab.browser.platform.CanMonitorPower(): 77 if not tab.browser.platform.CanMonitorPower():
78 return 78 return
79 79
80 self._StopInternal() 80 self._StopInternal()
81 81
82 def AddResults(self, _, results): 82 def AddResults(self, _, results, prefix=''):
83 if not self._results: 83 if not self._results:
84 return 84 return
85 85
86 energy_consumption_mwh = self._results.get('energy_consumption_mwh') 86 energy_consumption_mwh = self._results.get('energy_consumption_mwh')
87 # Testing for None, as 0 is a valid value. 87 # Testing for None, as 0 is a valid value.
88 if energy_consumption_mwh is not None: 88 if energy_consumption_mwh is not None:
89 results.Add('energy_consumption_mwh', 'mWh', energy_consumption_mwh) 89 results.Add('%senergy_consumption_mwh' % prefix, 'mWh',
90 energy_consumption_mwh)
90 91
91 component_utilization = self._results.get('component_utilization', {}) 92 component_utilization = self._results.get('component_utilization', {})
92 # GPU Frequency. 93 # GPU Frequency.
93 gpu_power = component_utilization.get('gpu', {}) 94 gpu_power = component_utilization.get('gpu', {})
94 gpu_freq_hz = gpu_power.get('average_frequency_hz') 95 gpu_freq_hz = gpu_power.get('average_frequency_hz')
95 # Testing for None, as 0 is a valid value. 96 # Testing for None, as 0 is a valid value.
96 if gpu_freq_hz is not None: 97 if gpu_freq_hz is not None:
97 results.Add('gpu_average_frequency_hz', 'hz', gpu_freq_hz) 98 results.Add('%sgpu_average_frequency_hz' % prefix, 'hz', gpu_freq_hz)
98 99
99 # Add idle wakeup numbers for all processes. 100 # Add idle wakeup numbers for all processes.
100 for (process_type, stats) in self._results.get('cpu_stats', {}).items(): 101 for (process_type, stats) in self._results.get('cpu_stats', {}).items():
101 trace_name_for_process = 'idle_wakeups_%s' % (process_type.lower()) 102 trace_name_for_process = '%sidle_wakeups_%s' % (prefix,
103 process_type.lower())
102 results.Add(trace_name_for_process, 'count', stats) 104 results.Add(trace_name_for_process, 'count', stats)
103 105
104 self._results = None 106 self._results = None
105 107
106 def _SubtractCpuStats(cpu_stats, start_cpu_stats): 108 def _SubtractCpuStats(cpu_stats, start_cpu_stats):
107 """Computes number of idle wakeups that occurred over measurement period. 109 """Computes number of idle wakeups that occurred over measurement period.
108 110
109 Each of the two cpu_stats arguments is a dict as returned by the 111 Each of the two cpu_stats arguments is a dict as returned by the
110 Browser.cpu_stats call. 112 Browser.cpu_stats call.
111 113
112 Returns: 114 Returns:
113 A dict of process type names (Browser, Renderer, etc.) to idle wakeup count 115 A dict of process type names (Browser, Renderer, etc.) to idle wakeup count
114 over the period recorded by the input. 116 over the period recorded by the input.
115 """ 117 """
116 cpu_delta = {} 118 cpu_delta = {}
117 for process_type in cpu_stats: 119 for process_type in cpu_stats:
118 assert process_type in start_cpu_stats, 'Mismatching process types' 120 assert process_type in start_cpu_stats, 'Mismatching process types'
119 # Skip any process_types that are empty. 121 # Skip any process_types that are empty.
120 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]): 122 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]):
121 continue 123 continue
122 # Skip if IdleWakeupCount is not present. 124 # Skip if IdleWakeupCount is not present.
123 if (('IdleWakeupCount' not in cpu_stats[process_type]) or 125 if (('IdleWakeupCount' not in cpu_stats[process_type]) or
124 ('IdleWakeupCount' not in start_cpu_stats[process_type])): 126 ('IdleWakeupCount' not in start_cpu_stats[process_type])):
125 continue 127 continue
126 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] - 128 idle_wakeup_delta = (cpu_stats[process_type]['IdleWakeupCount'] -
127 start_cpu_stats[process_type]['IdleWakeupCount']) 129 start_cpu_stats[process_type]['IdleWakeupCount'])
128 cpu_delta[process_type] = idle_wakeup_delta 130 cpu_delta[process_type] = idle_wakeup_delta
129 return cpu_delta 131 return cpu_delta
OLDNEW
« no previous file with comments | « tools/perf/measurements/page_cycler.py ('k') | tools/telemetry/telemetry/page/page_measurement.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698