telemetry.page.page_measurement
index
telemetry/page/page_measurement.py

# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

 
Modules
       
telemetry.page.block_page_measurement_results
telemetry.page.buildbot_page_measurement_results
telemetry.page.csv_page_measurement_results
os
telemetry.page.page_measurement_results
telemetry.page.page_test
sys

 
Classes
       
telemetry.page.page_test.Failure(exceptions.Exception)
MeasurementFailure
telemetry.page.page_test.PageTest(__builtin__.object)
PageMeasurement

 
class MeasurementFailure(telemetry.page.page_test.Failure)
    Exception that can be thrown from MeasurePage to indicate an undesired but
designed-for problem.
 
 
Method resolution order:
MeasurementFailure
telemetry.page.page_test.Failure
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from telemetry.page.page_test.Failure:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class PageMeasurement(telemetry.page.page_test.PageTest)
    Glue code for running a measurement across a set of pages.
 
To use this, subclass from the measurement and override MeasurePage. For
example:
 
   class BodyChildElementMeasurement(PageMeasurement):
      def MeasurePage(self, page, tab, results):
         body_child_count = tab.EvaluateJavaScript(
             'document.body.children.length')
         results.Add('body_children', 'count', body_child_count)
 
   if __name__ == '__main__':
       page_measurement.Main(BodyChildElementMeasurement())
 
To add test-specific options:
 
   class BodyChildElementMeasurement(PageMeasurement):
      def AddCommandLineOptions(parser):
         parser.add_option('--element', action='store', default='body')
 
      def MeasurePage(self, page, tab, results):
         body_child_count = tab.EvaluateJavaScript(
            'document.querySelector('%s').children.length')
         results.Add('children', 'count', child_count)
 
 
Method resolution order:
PageMeasurement
telemetry.page.page_test.PageTest
__builtin__.object

Methods defined here:
AddOutputOptions(self, parser)
MeasurePage(self, page, tab, results)
Override to actually measure the page's performance.
 
page is a page_set.Page
tab is an instance of telemetry.core.Tab
 
Should call results.Add(name, units, value) for each result, or raise an
exception on failure. The name and units of each Add() call must be
the same across all iterations. The name 'url' must not be used.
 
Prefer field names that are in accordance with python variable style. E.g.
field_name.
 
Put together:
 
   def MeasurePage(self, page, tab, results):
     res = tab.EvaluateJavaScript('2+2')
     if res != 4:
       raise Exception('Oh, wow.')
     results.Add('two_plus_two', 'count', res)
PrepareResults(self, options)
__init__(self, action_name_to_run='', needs_browser_restart_after_each_run=False, discard_first_result=False, clear_cache_before_each_run=False)

Data descriptors defined here:
output_format_choices
results_are_the_same_on_every_page
By default, measurements are assumed to output the same values for every
page. This allows incremental output, for example in CSV. If, however, the
measurement discovers what values it can report as it goes, and those values
may vary from page to page, you need to override this function and return
False. Output will not appear in this mode until the entire pageset has
run.

Methods inherited from telemetry.page.page_test.PageTest:
AddCommandLineOptions(self, parser)
Override to expose command-line options for this test.
 
The provided parser is an optparse.OptionParser instance and accepts all
normal results. The parsed options are available in Run as
self.options.
CanRunForPage(self, page)
Override to customize if the test can be ran for the given page.
CreatePageSet(self, args, options)
Override to make this test generate its own page set instead of
allowing arbitrary page sets entered from the command-line.
CustomizeBrowserOptions(self, options)
Override to add test-specific options to the BrowserOptions object
CustomizeBrowserOptionsForPage(self, page, options)
Add options specific to the test and the given page.
DidNavigateToPage(self, page, tab)
Override to do operations right after the page is navigated, but before
any waiting for completion has occurred.
DidRunAction(self, page, tab, action)
Override to do operations after running the action on the page.
DidRunPageSet(self, tab, results)
Override to do operations after page set is completed, but before browser
is torn down.
DidStartHTTPServer(self, tab)
Override to do operations after the HTTP server is started.
NeedsBrowserRestartAfterEachRun(self, tab)
Override to specify browser restart after each run.
Run(self, options, page, tab, results)
SetUpBrowser(self, browser)
Override to customize the browser right after it has launched.
WillNavigateToPage(self, page, tab)
Override to do operations before the page is navigated.
WillRunAction(self, page, tab, action)
Override to do operations before running the action on the page.
WillRunPageSet(self, tab)
Override to do operations before the page set is navigated.

Data descriptors inherited from telemetry.page.page_test.PageTest:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
action_name_to_run
clear_cache_before_each_run
When set to True, the browser's disk and memory cache will be cleared
before each run.
discard_first_result
When set to True, the first run of the test is discarded.  This is
useful for cases where it's desirable to have some test resource cached so
the first run of the test can warm things up.