1 2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3<html><head><title>Python: module telemetry.internal.platform.power_monitor.cros_power_monitor</title> 4<meta charset="utf-8"> 5</head><body bgcolor="#f0f0f8"> 6 7<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> 8<tr bgcolor="#7799ee"> 9<td valign=bottom> <br> 10<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry.internal.html"><font color="#ffffff">internal</font></a>.<a href="telemetry.internal.platform.html"><font color="#ffffff">platform</font></a>.<a href="telemetry.internal.platform.power_monitor.html"><font color="#ffffff">power_monitor</font></a>.cros_power_monitor</strong></big></big></font></td 11><td align=right valign=bottom 12><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="../telemetry/internal/platform/power_monitor/cros_power_monitor.py">telemetry/internal/platform/power_monitor/cros_power_monitor.py</a></font></td></tr></table> 13 <p><tt># Copyright 2014 The Chromium Authors. All rights reserved.<br> 14# Use of this source code is governed by a BSD-style license that can be<br> 15# found in the LICENSE file.</tt></p> 16<p> 17<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 18<tr bgcolor="#aa55cc"> 19<td colspan=3 valign=bottom> <br> 20<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> 21 22<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> 23<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="collections.html">collections</a><br> 24</td><td width="25%" valign=top><a href="telemetry.decorators.html">telemetry.decorators</a><br> 25</td><td width="25%" valign=top><a href="re.html">re</a><br> 26</td><td width="25%" valign=top><a href="telemetry.internal.platform.power_monitor.sysfs_power_monitor.html">telemetry.internal.platform.power_monitor.sysfs_power_monitor</a><br> 27</td></tr></table></td></tr></table><p> 28<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 29<tr bgcolor="#ee77aa"> 30<td colspan=3 valign=bottom> <br> 31<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> 32 33<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> 34<td width="100%"><dl> 35<dt><font face="helvetica, arial"><a href="telemetry.internal.platform.power_monitor.sysfs_power_monitor.html#SysfsPowerMonitor">telemetry.internal.platform.power_monitor.sysfs_power_monitor.SysfsPowerMonitor</a>(<a href="telemetry.internal.platform.power_monitor.html#PowerMonitor">telemetry.internal.platform.power_monitor.PowerMonitor</a>) 36</font></dt><dd> 37<dl> 38<dt><font face="helvetica, arial"><a href="telemetry.internal.platform.power_monitor.cros_power_monitor.html#CrosPowerMonitor">CrosPowerMonitor</a> 39</font></dt></dl> 40</dd> 41</dl> 42 <p> 43<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 44<tr bgcolor="#ffc8d8"> 45<td colspan=3 valign=bottom> <br> 46<font color="#000000" face="helvetica, arial"><a name="CrosPowerMonitor">class <strong>CrosPowerMonitor</strong></a>(<a href="telemetry.internal.platform.power_monitor.sysfs_power_monitor.html#SysfsPowerMonitor">telemetry.internal.platform.power_monitor.sysfs_power_monitor.SysfsPowerMonitor</a>)</font></td></tr> 47 48<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> 49<td colspan=2><tt>PowerMonitor that relies on 'dump_power_status' to monitor power<br> 50consumption of a single ChromeOS application.<br> </tt></td></tr> 51<tr><td> </td> 52<td width="100%"><dl><dt>Method resolution order:</dt> 53<dd><a href="telemetry.internal.platform.power_monitor.cros_power_monitor.html#CrosPowerMonitor">CrosPowerMonitor</a></dd> 54<dd><a href="telemetry.internal.platform.power_monitor.sysfs_power_monitor.html#SysfsPowerMonitor">telemetry.internal.platform.power_monitor.sysfs_power_monitor.SysfsPowerMonitor</a></dd> 55<dd><a href="telemetry.internal.platform.power_monitor.html#PowerMonitor">telemetry.internal.platform.power_monitor.PowerMonitor</a></dd> 56<dd><a href="__builtin__.html#object">__builtin__.object</a></dd> 57</dl> 58<hr> 59Methods defined here:<br> 60<dl><dt><a name="CrosPowerMonitor-CanMonitorPower"><strong>CanMonitorPower</strong></a>(*args, **kwargs)</dt></dl> 61 62<dl><dt><a name="CrosPowerMonitor-StartMonitoringPower"><strong>StartMonitoringPower</strong></a>(self, browser)</dt></dl> 63 64<dl><dt><a name="CrosPowerMonitor-StopMonitoringPower"><strong>StopMonitoringPower</strong></a>(self)</dt></dl> 65 66<dl><dt><a name="CrosPowerMonitor-__init__"><strong>__init__</strong></a>(self, platform_backend)</dt><dd><tt>Constructor.<br> 67 <br> 68Args:<br> 69 platform_backend: A LinuxBasedPlatformBackend object.<br> 70 <br> 71Attributes:<br> 72 _initial_power: The result of 'dump_power_status' before the test.<br> 73 _start_time: The epoch time at which the test starts executing.</tt></dd></dl> 74 75<hr> 76Static methods defined here:<br> 77<dl><dt><a name="CrosPowerMonitor-IsOnBatteryPower"><strong>IsOnBatteryPower</strong></a>(status, board)</dt><dd><tt>Determines if the devices is being charged.<br> 78 <br> 79Args:<br> 80 status: The parsed result of 'dump_power_status'<br> 81 board: The name of the board running the test.<br> 82 <br> 83Returns:<br> 84 True if the device is on battery power; False otherwise.</tt></dd></dl> 85 86<dl><dt><a name="CrosPowerMonitor-ParsePower"><strong>ParsePower</strong></a>(initial_stats, final_stats, length_h)</dt><dd><tt>Parse output of 'dump_power_status'<br> 87 <br> 88Args:<br> 89 initial_stats: The output of 'dump_power_status' before the test.<br> 90 final_stats: The output of 'dump_power_status' after the test.<br> 91 length_h: The length of the test in hours.<br> 92 <br> 93Returns:<br> 94 Dictionary in the format returned by <a href="#CrosPowerMonitor-StopMonitoringPower">StopMonitoringPower</a>().</tt></dd></dl> 95 96<dl><dt><a name="CrosPowerMonitor-ParsePowerStatus"><strong>ParsePowerStatus</strong></a>(sample)</dt><dd><tt>Parses 'dump_power_status' command output.<br> 97 <br> 98Args:<br> 99 sample: The output of 'dump_power_status'<br> 100 <br> 101Returns:<br> 102 Dictionary containing all fields from 'dump_power_status'</tt></dd></dl> 103 104<dl><dt><a name="CrosPowerMonitor-SplitSample"><strong>SplitSample</strong></a>(sample)</dt><dd><tt>Splits a power and time sample into the two separate values.<br> 105 <br> 106Args:<br> 107 sample: The result of calling 'dump_power_status; date +%s' on the<br> 108 device.<br> 109 <br> 110Returns:<br> 111 A tuple of power sample and epoch time of the sample.</tt></dd></dl> 112 113<hr> 114Methods inherited from <a href="telemetry.internal.platform.power_monitor.sysfs_power_monitor.html#SysfsPowerMonitor">telemetry.internal.platform.power_monitor.sysfs_power_monitor.SysfsPowerMonitor</a>:<br> 115<dl><dt><a name="CrosPowerMonitor-GetCpuFreq"><strong>GetCpuFreq</strong></a>(self)</dt><dd><tt>Retrieve CPU frequency times from the device.<br> 116 <br> 117Returns:<br> 118 Dictionary containing frequency times for each CPU.</tt></dd></dl> 119 120<dl><dt><a name="CrosPowerMonitor-GetCpuState"><strong>GetCpuState</strong></a>(self)</dt><dd><tt>Retrieve CPU c-state residency times from the device.<br> 121 <br> 122Returns:<br> 123 Dictionary containing c-state residency times for each CPU.</tt></dd></dl> 124 125<hr> 126Static methods inherited from <a href="telemetry.internal.platform.power_monitor.sysfs_power_monitor.html#SysfsPowerMonitor">telemetry.internal.platform.power_monitor.sysfs_power_monitor.SysfsPowerMonitor</a>:<br> 127<dl><dt><a name="CrosPowerMonitor-CombineResults"><strong>CombineResults</strong></a>(cpu_stats, power_stats)</dt><dd><tt>Add frequency and c-state residency data to the power data.<br> 128 <br> 129Args:<br> 130 cpu_stats: Dictionary containing CPU statistics.<br> 131 power_stats: Dictionary containing power statistics.<br> 132 <br> 133Returns:<br> 134 Dictionary in the format returned by StopMonitoringPower.</tt></dd></dl> 135 136<dl><dt><a name="CrosPowerMonitor-ComputeCpuStats"><strong>ComputeCpuStats</strong></a>(initial, final)</dt><dd><tt>Parse the CPU c-state and frequency values saved during monitoring.<br> 137 <br> 138Args:<br> 139 initial: The parsed dictionary of initial statistics to be converted<br> 140 into percentages.<br> 141 final: The parsed dictionary of final statistics to be converted<br> 142 into percentages.<br> 143 <br> 144Returns:<br> 145 Dictionary containing percentages for each CPU as well as an average<br> 146 across all CPUs.</tt></dd></dl> 147 148<dl><dt><a name="CrosPowerMonitor-ParseFreqSample"><strong>ParseFreqSample</strong></a>(sample)</dt><dd><tt>Parse a single frequency sample.<br> 149 <br> 150Args:<br> 151 sample: The single sample of frequency data to be parsed.<br> 152 <br> 153Returns:<br> 154 A dictionary associating a frequency with a time.</tt></dd></dl> 155 156<hr> 157Methods inherited from <a href="telemetry.internal.platform.power_monitor.html#PowerMonitor">telemetry.internal.platform.power_monitor.PowerMonitor</a>:<br> 158<dl><dt><a name="CrosPowerMonitor-CanMeasurePerApplicationPower"><strong>CanMeasurePerApplicationPower</strong></a>(self)</dt><dd><tt>Returns True if the power monitor can measure power for the target<br> 159application in isolation. False if power measurement is for full system<br> 160energy consumption.</tt></dd></dl> 161 162<hr> 163Data descriptors inherited from <a href="telemetry.internal.platform.power_monitor.html#PowerMonitor">telemetry.internal.platform.power_monitor.PowerMonitor</a>:<br> 164<dl><dt><strong>__dict__</strong></dt> 165<dd><tt>dictionary for instance variables (if defined)</tt></dd> 166</dl> 167<dl><dt><strong>__weakref__</strong></dt> 168<dd><tt>list of weak references to the object (if defined)</tt></dd> 169</dl> 170</td></tr></table></td></tr></table> 171</body></html>