1 2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3<html><head><title>Python: module telemetry.benchmark</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>.benchmark</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/benchmark.py">telemetry/benchmark.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="telemetry.internal.util.command_line.html">telemetry.internal.util.command_line</a><br> 24<a href="telemetry.decorators.html">telemetry.decorators</a><br> 25</td><td width="25%" valign=top><a href="optparse.html">optparse</a><br> 26<a href="telemetry.page.page_test.html">telemetry.page.page_test</a><br> 27</td><td width="25%" valign=top><a href="telemetry.internal.story_runner.html">telemetry.internal.story_runner</a><br> 28<a href="telemetry.web_perf.timeline_based_measurement.html">telemetry.web_perf.timeline_based_measurement</a><br> 29</td><td width="25%" valign=top></td></tr></table></td></tr></table><p> 30<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 31<tr bgcolor="#ee77aa"> 32<td colspan=3 valign=bottom> <br> 33<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> 34 35<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> 36<td width="100%"><dl> 37<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> 38</font></dt><dd> 39<dl> 40<dt><font face="helvetica, arial"><a href="telemetry.benchmark.html#BenchmarkMetadata">BenchmarkMetadata</a> 41</font></dt></dl> 42</dd> 43<dt><font face="helvetica, arial"><a href="exceptions.html#Exception">exceptions.Exception</a>(<a href="exceptions.html#BaseException">exceptions.BaseException</a>) 44</font></dt><dd> 45<dl> 46<dt><font face="helvetica, arial"><a href="telemetry.benchmark.html#InvalidOptionsError">InvalidOptionsError</a> 47</font></dt></dl> 48</dd> 49<dt><font face="helvetica, arial"><a href="telemetry.internal.util.command_line.html#Command">telemetry.internal.util.command_line.Command</a>(<a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">telemetry.internal.util.command_line.ArgumentHandlerMixIn</a>) 50</font></dt><dd> 51<dl> 52<dt><font face="helvetica, arial"><a href="telemetry.benchmark.html#Benchmark">Benchmark</a> 53</font></dt></dl> 54</dd> 55</dl> 56 <p> 57<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 58<tr bgcolor="#ffc8d8"> 59<td colspan=3 valign=bottom> <br> 60<font color="#000000" face="helvetica, arial"><a name="Benchmark">class <strong>Benchmark</strong></a>(<a href="telemetry.internal.util.command_line.html#Command">telemetry.internal.util.command_line.Command</a>)</font></td></tr> 61 62<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> 63<td colspan=2><tt>Base class for a Telemetry benchmark.<br> 64 <br> 65A benchmark packages a measurement and a PageSet together.<br> 66Benchmarks default to using TBM unless you override the value of<br> 67<a href="#Benchmark">Benchmark</a>.test, or override the CreatePageTest method.<br> 68 <br> 69New benchmarks should override CreateStorySet.<br> </tt></td></tr> 70<tr><td> </td> 71<td width="100%"><dl><dt>Method resolution order:</dt> 72<dd><a href="telemetry.benchmark.html#Benchmark">Benchmark</a></dd> 73<dd><a href="telemetry.internal.util.command_line.html#Command">telemetry.internal.util.command_line.Command</a></dd> 74<dd><a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">telemetry.internal.util.command_line.ArgumentHandlerMixIn</a></dd> 75<dd><a href="__builtin__.html#object">__builtin__.object</a></dd> 76</dl> 77<hr> 78Methods defined here:<br> 79<dl><dt><a name="Benchmark-CreatePageTest"><strong>CreatePageTest</strong></a>(self, options)</dt><dd><tt>Return the PageTest for this <a href="#Benchmark">Benchmark</a>.<br> 80 <br> 81Override this method for PageTest tests.<br> 82Override, override CreateTimelineBasedMeasurementOptions to configure<br> 83TimelineBasedMeasurement tests. Do not override both methods.<br> 84 <br> 85Args:<br> 86 options: a browser_options.BrowserFinderOptions instance<br> 87Returns:<br> 88 |<a href="#Benchmark-test">test</a>()| if |test| is a PageTest class.<br> 89 Otherwise, a TimelineBasedMeasurement instance.</tt></dd></dl> 90 91<dl><dt><a name="Benchmark-CreateStorySet"><strong>CreateStorySet</strong></a>(self, options)</dt><dd><tt>Creates the instance of StorySet used to run the benchmark.<br> 92 <br> 93Can be overridden by subclasses.</tt></dd></dl> 94 95<dl><dt><a name="Benchmark-CreateTimelineBasedMeasurementOptions"><strong>CreateTimelineBasedMeasurementOptions</strong></a>(self)</dt><dd><tt>Return the TimelineBasedMeasurementOptions for this <a href="#Benchmark">Benchmark</a>.<br> 96 <br> 97Override this method to configure a TimelineBasedMeasurement benchmark.<br> 98Otherwise, override CreatePageTest for PageTest tests. Do not override<br> 99both methods.</tt></dd></dl> 100 101<dl><dt><a name="Benchmark-CustomizeBrowserOptions"><strong>CustomizeBrowserOptions</strong></a>(self, options)</dt><dd><tt>Add browser options that are required by this benchmark.</tt></dd></dl> 102 103<dl><dt><a name="Benchmark-GetMetadata"><strong>GetMetadata</strong></a>(self)</dt></dl> 104 105<dl><dt><a name="Benchmark-GetTraceRerunCommands"><strong>GetTraceRerunCommands</strong></a>(self)</dt></dl> 106 107<dl><dt><a name="Benchmark-Run"><strong>Run</strong></a>(self, finder_options)</dt><dd><tt>Do not override this method.</tt></dd></dl> 108 109<dl><dt><a name="Benchmark-SetupBenchmarkDebugTraceRerunOptions"><strong>SetupBenchmarkDebugTraceRerunOptions</strong></a>(self, tbm_options)</dt><dd><tt>Setup tracing categories associated with debug trace option.</tt></dd></dl> 110 111<dl><dt><a name="Benchmark-SetupBenchmarkDefaultTraceRerunOptions"><strong>SetupBenchmarkDefaultTraceRerunOptions</strong></a>(self, tbm_options)</dt><dd><tt>Setup tracing categories associated with default trace option.</tt></dd></dl> 112 113<dl><dt><a name="Benchmark-SetupTraceRerunOptions"><strong>SetupTraceRerunOptions</strong></a>(self, browser_options, tbm_options)</dt></dl> 114 115<dl><dt><a name="Benchmark-__init__"><strong>__init__</strong></a>(self, max_failures<font color="#909090">=None</font>)</dt><dd><tt>Creates a new <a href="#Benchmark">Benchmark</a>.<br> 116 <br> 117Args:<br> 118 max_failures: The number of story run's failures before bailing<br> 119 from executing subsequent page runs. If None, we never bail.</tt></dd></dl> 120 121<hr> 122Class methods defined here:<br> 123<dl><dt><a name="Benchmark-AddCommandLineArgs"><strong>AddCommandLineArgs</strong></a>(cls, parser)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl> 124 125<dl><dt><a name="Benchmark-HasTraceRerunDebugOption"><strong>HasTraceRerunDebugOption</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl> 126 127<dl><dt><a name="Benchmark-Name"><strong>Name</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl> 128 129<dl><dt><a name="Benchmark-ProcessCommandLineArgs"><strong>ProcessCommandLineArgs</strong></a>(cls, parser, args)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl> 130 131<dl><dt><a name="Benchmark-SetArgumentDefaults"><strong>SetArgumentDefaults</strong></a>(cls, parser)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl> 132 133<dl><dt><a name="Benchmark-ShouldDisable"><strong>ShouldDisable</strong></a>(cls, possible_browser)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Override this method to disable a benchmark under specific conditions.<br> 134 <br> 135Supports logic too complex for simple Enabled and Disabled decorators.<br> 136Decorators are still respected in cases where this function returns False.</tt></dd></dl> 137 138<dl><dt><a name="Benchmark-ValueCanBeAddedPredicate"><strong>ValueCanBeAddedPredicate</strong></a>(cls, value, is_first_result)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Returns whether |value| can be added to the test results.<br> 139 <br> 140Override this method to customize the logic of adding values to test<br> 141results.<br> 142 <br> 143Args:<br> 144 value: a value.Value instance (except failure.FailureValue,<br> 145 skip.SkipValue or trace.TraceValue which will always be added).<br> 146 is_first_result: True if |value| is the first result for its<br> 147 corresponding story.<br> 148 <br> 149Returns:<br> 150 True if |value| should be added to the test results.<br> 151 Otherwise, it returns False.</tt></dd></dl> 152 153<hr> 154Data descriptors defined here:<br> 155<dl><dt><strong>max_failures</strong></dt> 156</dl> 157<hr> 158Data and other attributes defined here:<br> 159<dl><dt><strong>options</strong> = {}</dl> 160 161<dl><dt><strong>test</strong> = <class 'telemetry.web_perf.timeline_based_measurement.TimelineBasedMeasurement'><dd><tt>Collects multiple metrics based on their interaction records.<br> 162 <br> 163A timeline based measurement shifts the burden of what metrics to collect onto<br> 164the story under test. Instead of the measurement<br> 165having a fixed set of values it collects, the story being tested<br> 166issues (via javascript) an Interaction record into the user timing API that<br> 167describing what is happening at that time, as well as a standardized set<br> 168of flags describing the semantics of the work being done. The<br> 169TimelineBasedMeasurement <a href="__builtin__.html#object">object</a> collects a trace that includes both these<br> 170interaction records, and a user-chosen amount of performance data using<br> 171Telemetry's various timeline-producing APIs, tracing especially.<br> 172 <br> 173It then passes the recorded timeline to different TimelineBasedMetrics based<br> 174on those flags. As an example, this allows a single story run to produce<br> 175load timing data, smoothness data, critical jank information and overall cpu<br> 176usage information.<br> 177 <br> 178For information on how to mark up a page to work with<br> 179TimelineBasedMeasurement, refer to the<br> 180perf.metrics.timeline_interaction_record module.<br> 181 <br> 182Args:<br> 183 options: an instance of timeline_based_measurement.Options.<br> 184 results_wrapper: A class that has the __init__ method takes in<br> 185 the page_test_results <a href="__builtin__.html#object">object</a> and the interaction record label. This<br> 186 class follows the ResultsWrapperInterface. Note: this class is not<br> 187 supported long term and to be removed when crbug.com/453109 is resolved.</tt></dl> 188 189<hr> 190Class methods inherited from <a href="telemetry.internal.util.command_line.html#Command">telemetry.internal.util.command_line.Command</a>:<br> 191<dl><dt><a name="Benchmark-Description"><strong>Description</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl> 192 193<dl><dt><a name="Benchmark-main"><strong>main</strong></a>(cls, args<font color="#909090">=None</font>)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Main method to run this command as a standalone script.</tt></dd></dl> 194 195<hr> 196Data descriptors inherited from <a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">telemetry.internal.util.command_line.ArgumentHandlerMixIn</a>:<br> 197<dl><dt><strong>__dict__</strong></dt> 198<dd><tt>dictionary for instance variables (if defined)</tt></dd> 199</dl> 200<dl><dt><strong>__weakref__</strong></dt> 201<dd><tt>list of weak references to the object (if defined)</tt></dd> 202</dl> 203</td></tr></table> <p> 204<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 205<tr bgcolor="#ffc8d8"> 206<td colspan=3 valign=bottom> <br> 207<font color="#000000" face="helvetica, arial"><a name="BenchmarkMetadata">class <strong>BenchmarkMetadata</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 208 209<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 210<td width="100%">Methods defined here:<br> 211<dl><dt><a name="BenchmarkMetadata-AsDict"><strong>AsDict</strong></a>(self)</dt></dl> 212 213<dl><dt><a name="BenchmarkMetadata-__init__"><strong>__init__</strong></a>(self, name, description<font color="#909090">=''</font>, rerun_options<font color="#909090">=None</font>)</dt></dl> 214 215<hr> 216Data descriptors defined here:<br> 217<dl><dt><strong>__dict__</strong></dt> 218<dd><tt>dictionary for instance variables (if defined)</tt></dd> 219</dl> 220<dl><dt><strong>__weakref__</strong></dt> 221<dd><tt>list of weak references to the object (if defined)</tt></dd> 222</dl> 223<dl><dt><strong>description</strong></dt> 224</dl> 225<dl><dt><strong>name</strong></dt> 226</dl> 227<dl><dt><strong>rerun_options</strong></dt> 228</dl> 229</td></tr></table> <p> 230<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 231<tr bgcolor="#ffc8d8"> 232<td colspan=3 valign=bottom> <br> 233<font color="#000000" face="helvetica, arial"><a name="InvalidOptionsError">class <strong>InvalidOptionsError</strong></a>(<a href="exceptions.html#Exception">exceptions.Exception</a>)</font></td></tr> 234 235<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> 236<td colspan=2><tt>Raised for invalid benchmark options.<br> </tt></td></tr> 237<tr><td> </td> 238<td width="100%"><dl><dt>Method resolution order:</dt> 239<dd><a href="telemetry.benchmark.html#InvalidOptionsError">InvalidOptionsError</a></dd> 240<dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd> 241<dd><a href="exceptions.html#BaseException">exceptions.BaseException</a></dd> 242<dd><a href="__builtin__.html#object">__builtin__.object</a></dd> 243</dl> 244<hr> 245Data descriptors defined here:<br> 246<dl><dt><strong>__weakref__</strong></dt> 247<dd><tt>list of weak references to the object (if defined)</tt></dd> 248</dl> 249<hr> 250Methods inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br> 251<dl><dt><a name="InvalidOptionsError-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#InvalidOptionsError-__init__">__init__</a>(...) initializes x; see help(type(x)) for signature</tt></dd></dl> 252 253<hr> 254Data and other attributes inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br> 255<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object><dd><tt>T.<a href="#InvalidOptionsError-__new__">__new__</a>(S, ...) -> a new <a href="__builtin__.html#object">object</a> with type S, a subtype of T</tt></dl> 256 257<hr> 258Methods inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br> 259<dl><dt><a name="InvalidOptionsError-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#InvalidOptionsError-__delattr__">__delattr__</a>('name') <==> del x.name</tt></dd></dl> 260 261<dl><dt><a name="InvalidOptionsError-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#InvalidOptionsError-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl> 262 263<dl><dt><a name="InvalidOptionsError-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#InvalidOptionsError-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl> 264 265<dl><dt><a name="InvalidOptionsError-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#InvalidOptionsError-__getslice__">__getslice__</a>(i, j) <==> x[i:j]<br> 266 <br> 267Use of negative indices is not supported.</tt></dd></dl> 268 269<dl><dt><a name="InvalidOptionsError-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl> 270 271<dl><dt><a name="InvalidOptionsError-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#InvalidOptionsError-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl> 272 273<dl><dt><a name="InvalidOptionsError-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#InvalidOptionsError-__setattr__">__setattr__</a>('name', value) <==> x.name = value</tt></dd></dl> 274 275<dl><dt><a name="InvalidOptionsError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl> 276 277<dl><dt><a name="InvalidOptionsError-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#InvalidOptionsError-__str__">__str__</a>() <==> str(x)</tt></dd></dl> 278 279<dl><dt><a name="InvalidOptionsError-__unicode__"><strong>__unicode__</strong></a>(...)</dt></dl> 280 281<hr> 282Data descriptors inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br> 283<dl><dt><strong>__dict__</strong></dt> 284</dl> 285<dl><dt><strong>args</strong></dt> 286</dl> 287<dl><dt><strong>message</strong></dt> 288</dl> 289</td></tr></table></td></tr></table><p> 290<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 291<tr bgcolor="#eeaa77"> 292<td colspan=3 valign=bottom> <br> 293<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> 294 295<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> 296<td width="100%"><dl><dt><a name="-AddCommandLineArgs"><strong>AddCommandLineArgs</strong></a>(parser)</dt></dl> 297 <dl><dt><a name="-ProcessCommandLineArgs"><strong>ProcessCommandLineArgs</strong></a>(parser, args)</dt></dl> 298</td></tr></table> 299</body></html>