Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# PerformanceTimeline

Reporting of performance timeline events, as specified in https://w3c.github.io/performance-timeline/#dom-performanceobserver.

This CDP domain is experimental.

- Types

- Commands

- Events

## Types

Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.

class LargestContentfulPaint(render_time, load_time, size, element_id=None, url=None, node_id=None)

  See https://github.com/WICG/LargestContentfulPaint and largest_contentful_paint.idl

  render_time: `TimeSinceEpoch`
  load_time: `TimeSinceEpoch`
  size: `float`

    The number of pixels being painted.

  element_id: `Optional`[`str`] = None

    The id attribute of the element, if available.

  url: `Optional`[`str`] = None

    The URL of the image (may be trimmed).

  node_id: `Optional`[`BackendNodeId`] = None

class LayoutShiftAttribution(previous_rect, current_rect, node_id=None)
  previous_rect: `Rect`
  current_rect: `Rect`
  node_id: `Optional`[`BackendNodeId`] = None

class LayoutShift(value, had_recent_input, last_input_time, sources)

  See https://wicg.github.io/layout-instability/#sec-layout-shift and layout_shift.idl

  value: `float`

    Score increment produced by this event.

  had_recent_input: `bool`
  last_input_time: `TimeSinceEpoch`
  sources: `List`[`LayoutShiftAttribution`]

class TimelineEvent(frame_id, type_, name, time, duration=None, lcp_details=None, layout_shift_details=None)
  frame_id: `FrameId`

    Identifies the frame that this event is related to. Empty for non-frame targets.

  type_: `str`

    //w3c.github.io/performance-timeline/#dom-performanceentry-entrytype This determines which of the optional “details” fields is present.

    Type:

      The event type, as specified in https

  name: `str`

    Name may be empty depending on the type.

  time: `TimeSinceEpoch`

    Time in seconds since Epoch, monotonically increasing within document lifetime.

  duration: `Optional`[`float`] = None

    Event duration, if applicable.

  lcp_details: `Optional`[`LargestContentfulPaint`] = None
  layout_shift_details: `Optional`[`LayoutShift`] = None

## Commands

Each command is a generator function. The return type `Generator[x, y, z]` indicates that the generator yields arguments of type `x`, it must be resumed with an argument of type `y`, and it returns type `z`. In this library, types `x` and `y` are the same for all commands, and `z` is the return type you should pay attention to. For more information, see Getting Started: Commands.

enable(event_types)

  Previously buffered events would be reported before method returns. See also: timelineEventAdded

  Parameters:

    event_types (`List`[`str`]) – The types of event to report, as specified in https://w3c.github.io/performance-timeline/#dom-performanceentry-entrytype The specified filter overrides any previous filters, passing empty filter disables recording. Note that not all types exposed to the web platform are currently supported.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

## Events

Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.

class TimelineEventAdded(event)

  Sent when a performance timeline event is added. See reportPerformanceTimeline method.

  event: `TimelineEvent`