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
5import logging
6
7from telemetry.core import exceptions
8
9
10class PowerMonitor(object):
11  """A power profiler.
12
13  Provides an interface to register power consumption during a test.
14  """
15  def __init__(self):
16    self._monitoring = False
17
18  def CanMonitorPower(self):
19    """Returns True iff power can be monitored asynchronously via
20    StartMonitoringPower() and StopMonitoringPower().
21    """
22    return False
23
24  def CanMeasurePerApplicationPower(self):
25    """Returns True if the power monitor can measure power for the target
26    application in isolation. False if power measurement is for full system
27    energy consumption."""
28    return False
29
30  def _CheckStart(self):
31    assert not self._monitoring, "Already monitoring power."
32    self._monitoring = True
33
34  def _CheckStop(self):
35    assert self._monitoring, "Not monitoring power."
36    self._monitoring = False
37
38  def StartMonitoringPower(self, browser):
39    """Starts monitoring power utilization statistics.
40
41    See Platform#StartMonitoringPower for the arguments format.
42    """
43    raise NotImplementedError()
44
45  def StopMonitoringPower(self):
46    """Stops monitoring power utilization and returns collects stats
47
48    See Platform#StopMonitoringPower for the return format.
49    """
50    raise NotImplementedError()
51