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

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

Issue 144543007: [Telemetry] Add power usage metric (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Whitespace fix Created 6 years, 10 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
« no previous file with comments | « tools/perf/measurements/smoothness.py ('k') | tools/perf/unit-info.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import logging
6
7 from metrics import Metric
8
9
10 class PowerMetric(Metric):
11 """A metric for measuring power usage."""
12
13 _enabed = True
14
15 def __init__(self):
16 super(PowerMetric, self).__init__()
17 self._results = None
18
19 @classmethod
20 def CustomizeBrowserOptions(cls, options):
21 PowerMetric._enabed = options.report_root_metrics
22
23 def Start(self, _, tab):
24 if not PowerMetric._enabed:
25 return
26
27 if not tab.browser.platform.CanMonitorPowerAsync():
28 logging.warning("System doesn't support async power monitoring.")
29 return
30
31 tab.browser.platform.StartMonitoringPowerAsync()
32
33 def Stop(self, _, tab):
34 if not PowerMetric._enabed:
35 return
36
37 if not tab.browser.platform.CanMonitorPowerAsync():
38 return
39
40 self._results = tab.browser.platform.StopMonitoringPowerAsync()
41
42 def AddResults(self, _, results):
43 if not self._results:
44 return
45
46 energy_consumption_mwh = self._results['energy_consumption_mwh']
47 results.Add('energy_consumption_mwh', 'mWh', energy_consumption_mwh)
48 self._results = None
OLDNEW
« no previous file with comments | « tools/perf/measurements/smoothness.py ('k') | tools/perf/unit-info.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698