1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module telemetry.page.page_measurement</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry.page.html"><font color="#ffffff">page</font></a>.page_measurement</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Users/nduca/Local/chrome/src/tools/telemetry/telemetry/page/page_measurement.py">/Users/nduca/Local/chrome/src/tools/telemetry/telemetry/page/page_measurement.py</a></font></td></tr></table>
<p><tt># Copyright (c) 2012 The Chromium Authors. All rights reserved.<br>
# Use of this source code is governed by a BSD-style license that can be<br>
# found in the LICENSE file.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="telemetry.page.block_page_measurement_results.html">telemetry.page.block_page_measurement_results</a><br>
<a href="telemetry.page.buildbot_page_measurement_results.html">telemetry.page.buildbot_page_measurement_results</a><br>
</td><td width="25%" valign=top><a href="telemetry.page.csv_page_measurement_results.html">telemetry.page.csv_page_measurement_results</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="telemetry.page.page_measurement_results.html">telemetry.page.page_measurement_results</a><br>
<a href="telemetry.page.page_test.html">telemetry.page.page_test</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="telemetry.page.page_test.html#Failure">telemetry.page.page_test.Failure</a>(<a href="exceptions.html#Exception">exceptions.Exception</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="telemetry.page.page_measurement.html#MeasurementFailure">MeasurementFailure</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="telemetry.page.page_test.html#PageTest">telemetry.page.page_test.PageTest</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="telemetry.page.page_measurement.html#PageMeasurement">PageMeasurement</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="MeasurementFailure">class <strong>MeasurementFailure</strong></a>(<a href="telemetry.page.page_test.html#Failure">telemetry.page.page_test.Failure</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Exception that can be thrown from MeasurePage to indicate an undesired but<br>
designed-for problem.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="telemetry.page.page_measurement.html#MeasurementFailure">MeasurementFailure</a></dd>
<dd><a href="telemetry.page.page_test.html#Failure">telemetry.page.page_test.Failure</a></dd>
<dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd>
<dd><a href="exceptions.html#BaseException">exceptions.BaseException</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Data descriptors inherited from <a href="telemetry.page.page_test.html#Failure">telemetry.page.page_test.Failure</a>:<br>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br>
<dl><dt><a name="MeasurementFailure-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#MeasurementFailure-__init__">__init__</a>(...) initializes x; see help(type(x)) for signature</tt></dd></dl>
<hr>
Data and other attributes inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br>
<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object><dd><tt>T.<a href="#MeasurementFailure-__new__">__new__</a>(S, ...) -> a new object with type S, a subtype of T</tt></dl>
<hr>
Methods inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
<dl><dt><a name="MeasurementFailure-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#MeasurementFailure-__delattr__">__delattr__</a>('name') <==> del x.name</tt></dd></dl>
<dl><dt><a name="MeasurementFailure-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#MeasurementFailure-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl>
<dl><dt><a name="MeasurementFailure-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#MeasurementFailure-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl>
<dl><dt><a name="MeasurementFailure-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#MeasurementFailure-__getslice__">__getslice__</a>(i, j) <==> x[i:j]<br>
<br>
Use of negative indices is not supported.</tt></dd></dl>
<dl><dt><a name="MeasurementFailure-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl>
<dl><dt><a name="MeasurementFailure-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#MeasurementFailure-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl>
<dl><dt><a name="MeasurementFailure-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#MeasurementFailure-__setattr__">__setattr__</a>('name', value) <==> x.name = value</tt></dd></dl>
<dl><dt><a name="MeasurementFailure-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
<dl><dt><a name="MeasurementFailure-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#MeasurementFailure-__str__">__str__</a>() <==> str(x)</tt></dd></dl>
<dl><dt><a name="MeasurementFailure-__unicode__"><strong>__unicode__</strong></a>(...)</dt></dl>
<hr>
Data descriptors inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
</dl>
<dl><dt><strong>args</strong></dt>
</dl>
<dl><dt><strong>message</strong></dt>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PageMeasurement">class <strong>PageMeasurement</strong></a>(<a href="telemetry.page.page_test.html#PageTest">telemetry.page.page_test.PageTest</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Glue code for running a measurement across a set of pages.<br>
<br>
To use this, subclass from the measurement and override MeasurePage. For<br>
example:<br>
<br>
class BodyChildElementMeasurement(<a href="#PageMeasurement">PageMeasurement</a>):<br>
def <a href="#PageMeasurement-MeasurePage">MeasurePage</a>(self, page, tab, results):<br>
body_child_count = tab.EvaluateJavaScript(<br>
'document.body.children.length')<br>
results.Add('body_children', 'count', body_child_count)<br>
<br>
if __name__ == '__main__':<br>
page_measurement.Main(BodyChildElementMeasurement())<br>
<br>
To add test-specific options:<br>
<br>
class BodyChildElementMeasurement(<a href="#PageMeasurement">PageMeasurement</a>):<br>
def <a href="#PageMeasurement-AddCommandLineOptions">AddCommandLineOptions</a>(parser):<br>
parser.add_option('--element', action='store', default='body')<br>
<br>
def <a href="#PageMeasurement-MeasurePage">MeasurePage</a>(self, page, tab, results):<br>
body_child_count = tab.EvaluateJavaScript(<br>
'document.querySelector('%s').children.length')<br>
results.Add('children', 'count', child_count)<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="telemetry.page.page_measurement.html#PageMeasurement">PageMeasurement</a></dd>
<dd><a href="telemetry.page.page_test.html#PageTest">telemetry.page.page_test.PageTest</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="PageMeasurement-AddOutputOptions"><strong>AddOutputOptions</strong></a>(self, parser)</dt></dl>
<dl><dt><a name="PageMeasurement-MeasurePage"><strong>MeasurePage</strong></a>(self, page, tab, results)</dt><dd><tt>Override to actually measure the page's performance.<br>
<br>
page is a page_set.Page<br>
tab is an instance of telemetry.core.Tab<br>
<br>
Should call results.Add(name, units, value) for each result, or raise an<br>
exception on failure. The name and units of each Add() call must be<br>
the same across all iterations. The name 'url' must not be used.<br>
<br>
Prefer field names that are in accordance with python variable style. E.g.<br>
field_name.<br>
<br>
Put together:<br>
<br>
def <a href="#PageMeasurement-MeasurePage">MeasurePage</a>(self, page, tab, results):<br>
res = tab.EvaluateJavaScript('2+2')<br>
if res != 4:<br>
raise Exception('Oh, wow.')<br>
results.Add('two_plus_two', 'count', res)</tt></dd></dl>
<dl><dt><a name="PageMeasurement-PrepareResults"><strong>PrepareResults</strong></a>(self, options)</dt></dl>
<dl><dt><a name="PageMeasurement-__init__"><strong>__init__</strong></a>(self, action_name_to_run<font color="#909090">=''</font>, needs_browser_restart_after_each_run<font color="#909090">=False</font>, discard_first_result<font color="#909090">=False</font>)</dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>output_format_choices</strong></dt>
</dl>
<dl><dt><strong>results_are_the_same_on_every_page</strong></dt>
<dd><tt>By default, measurements are assumed to output the same values for every<br>
page. This allows incremental output, for example in CSV. If, however, the<br>
measurement discovers what values it can report as it goes, and those values<br>
may vary from page to page, you need to override this function and return<br>
False. Output will not appear in this mode until the entire pageset has<br>
run.</tt></dd>
</dl>
<hr>
Methods inherited from <a href="telemetry.page.page_test.html#PageTest">telemetry.page.page_test.PageTest</a>:<br>
<dl><dt><a name="PageMeasurement-AddCommandLineOptions"><strong>AddCommandLineOptions</strong></a>(self, parser)</dt><dd><tt>Override to expose command-line options for this test.<br>
<br>
The provided parser is an optparse.OptionParser instance and accepts all<br>
normal results. The parsed options are available in Run as<br>
self.<strong>options</strong>.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-CanRunForPage"><strong>CanRunForPage</strong></a>(self, page)</dt><dd><tt>Override to customize if the test can be ran for the given page.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-CreatePageSet"><strong>CreatePageSet</strong></a>(self, args, options)</dt><dd><tt>Override to make this test generate its own page set instead of<br>
allowing arbitrary page sets entered from the command-line.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-CustomizeBrowserOptions"><strong>CustomizeBrowserOptions</strong></a>(self, options)</dt><dd><tt>Override to add test-specific options to the BrowserOptions object</tt></dd></dl>
<dl><dt><a name="PageMeasurement-CustomizeBrowserOptionsForPage"><strong>CustomizeBrowserOptionsForPage</strong></a>(self, page, options)</dt><dd><tt>Add options specific to the test and the given page.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-DidNavigateToPage"><strong>DidNavigateToPage</strong></a>(self, page, tab)</dt><dd><tt>Override to do operations right after the page is navigated, but before<br>
any waiting for completion has occurred.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-DidRunAction"><strong>DidRunAction</strong></a>(self, page, tab, action)</dt><dd><tt>Override to do operations after running the action on the page.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-DidRunPageSet"><strong>DidRunPageSet</strong></a>(self, tab, results)</dt><dd><tt>Override to do operations after page set is completed, but before browser<br>
is torn down.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-DidStartHTTPServer"><strong>DidStartHTTPServer</strong></a>(self, tab)</dt><dd><tt>Override to do operations after the HTTP server is started.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-NeedsBrowserRestartAfterEachRun"><strong>NeedsBrowserRestartAfterEachRun</strong></a>(self, tab)</dt><dd><tt>Override to specify browser restart after each run.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-Run"><strong>Run</strong></a>(self, options, page, tab, results)</dt></dl>
<dl><dt><a name="PageMeasurement-SetUpBrowser"><strong>SetUpBrowser</strong></a>(self, browser)</dt><dd><tt>Override to customize the browser right after it has launched.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-WillNavigateToPage"><strong>WillNavigateToPage</strong></a>(self, page, tab)</dt><dd><tt>Override to do operations before the page is navigated.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-WillRunAction"><strong>WillRunAction</strong></a>(self, page, tab, action)</dt><dd><tt>Override to do operations before running the action on the page.</tt></dd></dl>
<dl><dt><a name="PageMeasurement-WillRunPageSet"><strong>WillRunPageSet</strong></a>(self, tab)</dt><dd><tt>Override to do operations before the page set is navigated.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="telemetry.page.page_test.html#PageTest">telemetry.page.page_test.PageTest</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<dl><dt><strong>action_name_to_run</strong></dt>
</dl>
<dl><dt><strong>discard_first_result</strong></dt>
<dd><tt>When set to True, the first run of the test is discarded. This is<br>
useful for cases where it's desirable to have some test resource cached so<br>
the first run of the test can warm things up.</tt></dd>
</dl>
</td></tr></table></td></tr></table>
</body></html>
|