static getMainThreadTopLevelEventDurations(topLevelEvents, startTime = 0, endTime = Infinity) {
    // Find durations of all slices in range of interest.
    /** @type {Array<number>} */
    const durations = [];
    let clippedLength = 0;

    for (const event of topLevelEvents) {
      if (event.end < startTime || event.start > endTime) {
        continue;
      }

      let duration = event.duration;
      let eventStart = event.start;
      if (eventStart < startTime) {
        // Any part of task before window can be discarded.
        eventStart = startTime;
        duration = event.end - startTime;
      }

      if (event.end > endTime) {
        // Any part of task after window must be clipped but accounted for.
        clippedLength = duration - (endTime - eventStart);
      }

      durations.push(duration);
    }
    durations.sort((a, b) => a - b);

    return {
      durations,
      clippedLength,
    };
  }
Provides durations in ms of all main thread top-level events
@param {Array<ToplevelEvent>} topLevelEvents
@param {number} startTime Optional start time (in ms relative to timeOrigin) of range of interest. Defaults to 0.
@param {number} endTime Optional end time (in ms relative to timeOrigin) of range of interest. Defaults to trace end.
@return {{durations: Array<number>, clippedLength: number}}