startMeasureFrame function

void startMeasureFrame(
  1. Profile profile
)

Adds a marker indication the beginning of frame rendering.

This adds an event to the performance trace used to find measured frames in Chrome tracing data. The tracing data contains all frames, but some benchmarks are only interested in a subset of frames. For example, WidgetBuildRecorder only measures frames that build widgets, and ignores frames that clear the screen.

Warm-up frames are not measured. If profile.isWarmingUp is true, this function does nothing.

Implementation

void startMeasureFrame(Profile profile) {
  if (_calledStartMeasureFrame) {
    throw Exception('`startMeasureFrame` called twice in a row.');
  }

  _calledStartMeasureFrame = true;

  if (!profile.isWarmingUp) {
    // Tell the browser to mark the beginning of the frame.
    html.window.performance.mark('measured_frame_start#$_currentFrameNumber');

    _isMeasuringFrame = true;
  }
}