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>&nbsp;<br>
10<font color="#ffffff" face="helvetica, arial">&nbsp;<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>#&nbsp;Copyright&nbsp;2014&nbsp;The&nbsp;Chromium&nbsp;Authors.&nbsp;All&nbsp;rights&nbsp;reserved.<br>
14#&nbsp;Use&nbsp;of&nbsp;this&nbsp;source&nbsp;code&nbsp;is&nbsp;governed&nbsp;by&nbsp;a&nbsp;BSD-style&nbsp;license&nbsp;that&nbsp;can&nbsp;be<br>
15#&nbsp;found&nbsp;in&nbsp;the&nbsp;LICENSE&nbsp;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>&nbsp;<br>
20<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
21
22<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>&nbsp;<br>
31<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
32
33<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>&nbsp;<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>&nbsp;&nbsp;&nbsp;</tt></td>
49<td colspan=2><tt>PowerMonitor&nbsp;that&nbsp;relies&nbsp;on&nbsp;'dump_power_status'&nbsp;to&nbsp;monitor&nbsp;power<br>
50consumption&nbsp;of&nbsp;a&nbsp;single&nbsp;ChromeOS&nbsp;application.<br>&nbsp;</tt></td></tr>
51<tr><td>&nbsp;</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&nbsp;<br>
68Args:<br>
69&nbsp;&nbsp;&nbsp;&nbsp;platform_backend:&nbsp;A&nbsp;LinuxBasedPlatformBackend&nbsp;object.<br>
70&nbsp;<br>
71Attributes:<br>
72&nbsp;&nbsp;&nbsp;&nbsp;_initial_power:&nbsp;The&nbsp;result&nbsp;of&nbsp;'dump_power_status'&nbsp;before&nbsp;the&nbsp;test.<br>
73&nbsp;&nbsp;&nbsp;&nbsp;_start_time:&nbsp;The&nbsp;epoch&nbsp;time&nbsp;at&nbsp;which&nbsp;the&nbsp;test&nbsp;starts&nbsp;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&nbsp;if&nbsp;the&nbsp;devices&nbsp;is&nbsp;being&nbsp;charged.<br>
78&nbsp;<br>
79Args:<br>
80&nbsp;&nbsp;&nbsp;&nbsp;status:&nbsp;The&nbsp;parsed&nbsp;result&nbsp;of&nbsp;'dump_power_status'<br>
81&nbsp;&nbsp;&nbsp;&nbsp;board:&nbsp;The&nbsp;name&nbsp;of&nbsp;the&nbsp;board&nbsp;running&nbsp;the&nbsp;test.<br>
82&nbsp;<br>
83Returns:<br>
84&nbsp;&nbsp;&nbsp;&nbsp;True&nbsp;if&nbsp;the&nbsp;device&nbsp;is&nbsp;on&nbsp;battery&nbsp;power;&nbsp;False&nbsp;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&nbsp;output&nbsp;of&nbsp;'dump_power_status'<br>
87&nbsp;<br>
88Args:<br>
89&nbsp;&nbsp;&nbsp;&nbsp;initial_stats:&nbsp;The&nbsp;output&nbsp;of&nbsp;'dump_power_status'&nbsp;before&nbsp;the&nbsp;test.<br>
90&nbsp;&nbsp;&nbsp;&nbsp;final_stats:&nbsp;The&nbsp;output&nbsp;of&nbsp;'dump_power_status'&nbsp;after&nbsp;the&nbsp;test.<br>
91&nbsp;&nbsp;&nbsp;&nbsp;length_h:&nbsp;The&nbsp;length&nbsp;of&nbsp;the&nbsp;test&nbsp;in&nbsp;hours.<br>
92&nbsp;<br>
93Returns:<br>
94&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;in&nbsp;the&nbsp;format&nbsp;returned&nbsp;by&nbsp;<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&nbsp;'dump_power_status'&nbsp;command&nbsp;output.<br>
97&nbsp;<br>
98Args:<br>
99&nbsp;&nbsp;&nbsp;&nbsp;sample:&nbsp;The&nbsp;output&nbsp;of&nbsp;'dump_power_status'<br>
100&nbsp;<br>
101Returns:<br>
102&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;containing&nbsp;all&nbsp;fields&nbsp;from&nbsp;'dump_power_status'</tt></dd></dl>
103
104<dl><dt><a name="CrosPowerMonitor-SplitSample"><strong>SplitSample</strong></a>(sample)</dt><dd><tt>Splits&nbsp;a&nbsp;power&nbsp;and&nbsp;time&nbsp;sample&nbsp;into&nbsp;the&nbsp;two&nbsp;separate&nbsp;values.<br>
105&nbsp;<br>
106Args:<br>
107&nbsp;&nbsp;&nbsp;&nbsp;sample:&nbsp;The&nbsp;result&nbsp;of&nbsp;calling&nbsp;'dump_power_status;&nbsp;date&nbsp;+%s'&nbsp;on&nbsp;the<br>
108&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;device.<br>
109&nbsp;<br>
110Returns:<br>
111&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;tuple&nbsp;of&nbsp;power&nbsp;sample&nbsp;and&nbsp;epoch&nbsp;time&nbsp;of&nbsp;the&nbsp;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&nbsp;CPU&nbsp;frequency&nbsp;times&nbsp;from&nbsp;the&nbsp;device.<br>
116&nbsp;<br>
117Returns:<br>
118&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;containing&nbsp;frequency&nbsp;times&nbsp;for&nbsp;each&nbsp;CPU.</tt></dd></dl>
119
120<dl><dt><a name="CrosPowerMonitor-GetCpuState"><strong>GetCpuState</strong></a>(self)</dt><dd><tt>Retrieve&nbsp;CPU&nbsp;c-state&nbsp;residency&nbsp;times&nbsp;from&nbsp;the&nbsp;device.<br>
121&nbsp;<br>
122Returns:<br>
123&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;containing&nbsp;c-state&nbsp;residency&nbsp;times&nbsp;for&nbsp;each&nbsp;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&nbsp;frequency&nbsp;and&nbsp;c-state&nbsp;residency&nbsp;data&nbsp;to&nbsp;the&nbsp;power&nbsp;data.<br>
128&nbsp;<br>
129Args:<br>
130&nbsp;&nbsp;&nbsp;&nbsp;cpu_stats:&nbsp;Dictionary&nbsp;containing&nbsp;CPU&nbsp;statistics.<br>
131&nbsp;&nbsp;&nbsp;&nbsp;power_stats:&nbsp;Dictionary&nbsp;containing&nbsp;power&nbsp;statistics.<br>
132&nbsp;<br>
133Returns:<br>
134&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;in&nbsp;the&nbsp;format&nbsp;returned&nbsp;by&nbsp;StopMonitoringPower.</tt></dd></dl>
135
136<dl><dt><a name="CrosPowerMonitor-ComputeCpuStats"><strong>ComputeCpuStats</strong></a>(initial, final)</dt><dd><tt>Parse&nbsp;the&nbsp;CPU&nbsp;c-state&nbsp;and&nbsp;frequency&nbsp;values&nbsp;saved&nbsp;during&nbsp;monitoring.<br>
137&nbsp;<br>
138Args:<br>
139&nbsp;&nbsp;&nbsp;&nbsp;initial:&nbsp;The&nbsp;parsed&nbsp;dictionary&nbsp;of&nbsp;initial&nbsp;statistics&nbsp;to&nbsp;be&nbsp;converted<br>
140&nbsp;&nbsp;&nbsp;&nbsp;into&nbsp;percentages.<br>
141&nbsp;&nbsp;&nbsp;&nbsp;final:&nbsp;The&nbsp;parsed&nbsp;dictionary&nbsp;of&nbsp;final&nbsp;statistics&nbsp;to&nbsp;be&nbsp;converted<br>
142&nbsp;&nbsp;&nbsp;&nbsp;into&nbsp;percentages.<br>
143&nbsp;<br>
144Returns:<br>
145&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;containing&nbsp;percentages&nbsp;for&nbsp;each&nbsp;CPU&nbsp;as&nbsp;well&nbsp;as&nbsp;an&nbsp;average<br>
146&nbsp;&nbsp;&nbsp;&nbsp;across&nbsp;all&nbsp;CPUs.</tt></dd></dl>
147
148<dl><dt><a name="CrosPowerMonitor-ParseFreqSample"><strong>ParseFreqSample</strong></a>(sample)</dt><dd><tt>Parse&nbsp;a&nbsp;single&nbsp;frequency&nbsp;sample.<br>
149&nbsp;<br>
150Args:<br>
151&nbsp;&nbsp;&nbsp;&nbsp;sample:&nbsp;The&nbsp;single&nbsp;sample&nbsp;of&nbsp;frequency&nbsp;data&nbsp;to&nbsp;be&nbsp;parsed.<br>
152&nbsp;<br>
153Returns:<br>
154&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;dictionary&nbsp;associating&nbsp;a&nbsp;frequency&nbsp;with&nbsp;a&nbsp;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&nbsp;True&nbsp;if&nbsp;the&nbsp;power&nbsp;monitor&nbsp;can&nbsp;measure&nbsp;power&nbsp;for&nbsp;the&nbsp;target<br>
159application&nbsp;in&nbsp;isolation.&nbsp;False&nbsp;if&nbsp;power&nbsp;measurement&nbsp;is&nbsp;for&nbsp;full&nbsp;system<br>
160energy&nbsp;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&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
166</dl>
167<dl><dt><strong>__weakref__</strong></dt>
168<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
169</dl>
170</td></tr></table></td></tr></table>
171</body></html>