telemetry.web_perf.timeline_interaction_record
index
telemetry/web_perf/timeline_interaction_record.py

# Copyright 2014 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.decorators
re
telemetry.timeline.bounds

 
Classes
       
__builtin__.object
TimelineInteractionRecord
exceptions.Exception(exceptions.BaseException)
ThreadTimeRangeOverlappedException
NoThreadTimeDataException

 
class NoThreadTimeDataException(ThreadTimeRangeOverlappedException)
    Exception that can be thrown if there is not sufficient thread time data
to compute the overlapped thread time range.
 
 
Method resolution order:
NoThreadTimeDataException
ThreadTimeRangeOverlappedException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from ThreadTimeRangeOverlappedException:
__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 ThreadTimeRangeOverlappedException(exceptions.Exception)
    Exception that can be thrown when computing overlapped thread time range
with other events.
 
 
Method resolution order:
ThreadTimeRangeOverlappedException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__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 TimelineInteractionRecord(__builtin__.object)
    Represents an interaction that took place during a timeline recording.
 
As a page runs, typically a number of different (simulated) user interactions
take place. For instance, a user might click a button in a mail app causing a
popup to animate in. Then they might press another button that sends data to a
server and simultaneously closes the popup without an animation. These are two
interactions.
 
From the point of view of the page, each interaction might have a different
label: ClickComposeButton and SendEmail, for instance. From the point
of view of the benchmarking harness, the labels aren't so interesting as what
the performance expectations are for that interaction: was it loading
resources from the network? was there an animation?
 
Determining these things is hard to do, simply by observing the state given to
a page from javascript. There are hints, for instance if network requests are
sent, or if a CSS animation is pending. But this is by no means a complete
story.
 
Instead, we expect pages to mark up the timeline what they are doing, with
label and flags indicating the semantics of that interaction. This
is currently done by pushing markers into the console.time/timeEnd API: this
for instance can be issued in JS:
 
   var str = 'Interaction.SendEmail';
   console.time(str);
   setTimeout(function() {
     console.timeEnd(str);
   }, 1000);
 
When run with perf.measurements.timeline_based_measurement running, this will
then cause a TimelineInteractionRecord to be created for this range with
all metrics reported for the marked up 1000ms time-range.
 
The valid interaction flags are:
   * repeatable: Allows other interactions to use the same label
 
  Methods defined here:
GetBounds(*args, **kwargs)
GetOverlappedThreadTimeForSlice(self, timeline_slice)
Get the thread duration of timeline_slice that overlaps with this record.
 
There are two cases :
 
Case 1: timeline_slice runs in the same thread as the record.
 
              |    [       timeline_slice         ]
  THREAD 1    |                  |                              |
              |            record starts                    record ends
 
                  (relative order in thread time)
 
  As the thread timestamps in timeline_slice and record are consistent, we
  simply use them to compute the overlap.
 
Case 2: timeline_slice runs in a different thread from the record's.
 
              |
  THREAD 2    |    [       timeline_slice         ]
              |
 
              |
  THREAD 1    |               |                               |
              |          record starts                      record ends
 
                  (relative order in wall-time)
 
  Unlike case 1, thread timestamps of a thread are measured by its
  thread-specific clock, which is inconsistent with that of the other
  thread, and thus can't be used to compute the overlapped thread duration.
  Hence, we use a heuristic to compute the overlap (see
  _GetOverlappedThreadTimeForSliceInDifferentThread for more details)
 
Args:
  timeline_slice: An instance of telemetry.timeline.slice.Slice
__init__(self, label, start, end, async_event=None, flags=None)
__repr__(self)

Class methods defined here:
FromAsyncEvent(cls, async_event) from __builtin__.type
Construct an timeline_interaction_record from an async event.
Args:
  async_event: An instance of
    telemetry.timeline.async_slices.AsyncSlice

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
end
label
repeatable
start

 
Functions
       
GetJavaScriptMarker(label, flags)
Computes the marker string of an interaction record.
 
This marker string can be used with JavaScript API console.time()
and console.timeEnd() to mark the beginning and end of the
interaction record..
 
Args:
  label: The label used to identify the interaction record.
  flags: the flags for the interaction record see FLAGS above.
 
Returns:
  The interaction record marker string (e.g., Interaction.Label/flag1,flag2).
 
Raises:
  AssertionError: If one or more of the flags is unrecognized.
IsTimelineInteractionRecord(event_name)

 
Data
        FLAGS = ['repeatable']
REPEATABLE = 'repeatable'