@paulirish/trace_engine 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -17
- package/core/platform/ArrayUtilities.js.map +1 -1
- package/core/platform/DOMUtilities.js.map +1 -1
- package/core/platform/MapUtilities.d.ts +1 -0
- package/core/platform/MapUtilities.js +3 -0
- package/core/platform/MapUtilities.js.map +1 -1
- package/core/platform/MimeType.js +1 -0
- package/core/platform/MimeType.js.map +1 -1
- package/core/platform/NumberUtilities.js.map +1 -1
- package/core/platform/SetUtilities.js.map +1 -1
- package/core/platform/StringUtilities.js +3 -3
- package/core/platform/StringUtilities.js.map +1 -1
- package/core/platform/TypedArrayUtilities.d.ts +26 -0
- package/core/platform/TypedArrayUtilities.js +111 -0
- package/core/platform/TypedArrayUtilities.js.map +1 -0
- package/core/platform/TypescriptUtilities.js.map +1 -1
- package/core/platform/UserVisibleError.js.map +1 -1
- package/core/platform/platform-tsconfig.json +1 -0
- package/core/platform/platform.d.ts +2 -1
- package/core/platform/platform.js +2 -1
- package/core/platform/platform.js.map +1 -1
- package/generated/protocol.d.ts +163 -35
- package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
- package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
- package/models/trace/EntriesFilter.d.ts +7 -1
- package/models/trace/EntriesFilter.js +13 -2
- package/models/trace/EntriesFilter.js.map +1 -1
- package/models/trace/LegacyTracingModel.js.map +1 -1
- package/models/trace/ModelImpl.js.map +1 -1
- package/models/trace/Processor.js +45 -33
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/TracingManager.js.map +1 -1
- package/models/trace/extras/FetchNodes.d.ts +1 -1
- package/models/trace/extras/FetchNodes.js +1 -2
- package/models/trace/extras/FetchNodes.js.map +1 -1
- package/models/trace/extras/FilmStrip.js.map +1 -1
- package/models/trace/extras/MainThreadActivity.js.map +1 -1
- package/models/trace/extras/Metadata.d.ts +2 -2
- package/models/trace/extras/Metadata.js +10 -2
- package/models/trace/extras/Metadata.js.map +1 -1
- package/models/trace/handlers/AnimationHandler.js +1 -1
- package/models/trace/handlers/AnimationHandler.js.map +1 -1
- package/models/trace/handlers/AuctionWorkletsHandler.js.map +1 -1
- package/models/trace/handlers/ExtensionTraceDataHandler.d.ts +13 -0
- package/models/trace/handlers/ExtensionTraceDataHandler.js +93 -0
- package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -0
- package/models/trace/handlers/FramesHandler.js.map +1 -1
- package/models/trace/handlers/GPUHandler.js +1 -1
- package/models/trace/handlers/GPUHandler.js.map +1 -1
- package/models/trace/handlers/InitiatorsHandler.js +32 -3
- package/models/trace/handlers/InitiatorsHandler.js.map +1 -1
- package/models/trace/handlers/InvalidationsHandler.js +10 -1
- package/models/trace/handlers/InvalidationsHandler.js.map +1 -1
- package/models/trace/handlers/LargestImagePaintHandler.js +1 -1
- package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -1
- package/models/trace/handlers/LargestTextPaintHandler.js +1 -1
- package/models/trace/handlers/LargestTextPaintHandler.js.map +1 -1
- package/models/trace/handlers/LayerTreeHandler.js +3 -3
- package/models/trace/handlers/LayerTreeHandler.js.map +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.d.ts +5 -5
- package/models/trace/handlers/LayoutShiftsHandler.js +6 -5
- package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
- package/models/trace/handlers/MemoryHandler.js +1 -1
- package/models/trace/handlers/MemoryHandler.js.map +1 -1
- package/models/trace/handlers/MetaHandler.js +12 -10
- package/models/trace/handlers/MetaHandler.js.map +1 -1
- package/models/trace/handlers/ModelHandlers.d.ts +1 -0
- package/models/trace/handlers/ModelHandlers.js +1 -0
- package/models/trace/handlers/ModelHandlers.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.js +2 -2
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/PageLoadMetricsHandler.d.ts +11 -7
- package/models/trace/handlers/PageLoadMetricsHandler.js +11 -35
- package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
- package/models/trace/handlers/RendererHandler.js.map +1 -1
- package/models/trace/handlers/SamplesHandler.js +2 -2
- package/models/trace/handlers/SamplesHandler.js.map +1 -1
- package/models/trace/handlers/ScreenshotsHandler.js +2 -1
- package/models/trace/handlers/ScreenshotsHandler.js.map +1 -1
- package/models/trace/handlers/Threads.js.map +1 -1
- package/models/trace/handlers/UserInteractionsHandler.d.ts +2 -0
- package/models/trace/handlers/UserInteractionsHandler.js +21 -11
- package/models/trace/handlers/UserInteractionsHandler.js.map +1 -1
- package/models/trace/handlers/UserTimingsHandler.js +1 -0
- package/models/trace/handlers/UserTimingsHandler.js.map +1 -1
- package/models/trace/handlers/WarningsHandler.js +2 -2
- package/models/trace/handlers/WarningsHandler.js.map +1 -1
- package/models/trace/handlers/WorkersHandler.js +3 -3
- package/models/trace/handlers/WorkersHandler.js.map +1 -1
- package/models/trace/handlers/handlers-tsconfig.json +1 -0
- package/models/trace/handlers/types.js.map +1 -1
- package/models/trace/helpers/Extensions.d.ts +2 -0
- package/models/trace/helpers/Extensions.js +22 -0
- package/models/trace/helpers/Extensions.js.map +1 -0
- package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
- package/models/trace/helpers/Timing.js.map +1 -1
- package/models/trace/helpers/Trace.d.ts +4 -3
- package/models/trace/helpers/Trace.js +17 -3
- package/models/trace/helpers/Trace.js.map +1 -1
- package/models/trace/helpers/TreeHelpers.js.map +1 -1
- package/models/trace/helpers/helpers-tsconfig.json +1 -0
- package/models/trace/helpers/helpers.d.ts +1 -0
- package/models/trace/helpers/helpers.js +1 -0
- package/models/trace/helpers/helpers.js.map +1 -1
- package/models/trace/insights/InsightRunners.d.ts +2 -0
- package/models/trace/insights/InsightRunners.js +2 -0
- package/models/trace/insights/InsightRunners.js.map +1 -1
- package/models/trace/insights/InteractionToNextPaint.d.ts +9 -0
- package/models/trace/insights/InteractionToNextPaint.js +35 -0
- package/models/trace/insights/InteractionToNextPaint.js.map +1 -0
- package/models/trace/insights/LargestContentfulPaint.d.ts +31 -0
- package/models/trace/insights/LargestContentfulPaint.js +104 -0
- package/models/trace/insights/LargestContentfulPaint.js.map +1 -0
- package/models/trace/insights/RenderBlocking.js.map +1 -1
- package/models/trace/insights/insights-tsconfig.json +2 -0
- package/models/trace/insights/types.d.ts +3 -1
- package/models/trace/insights/types.js +3 -0
- package/models/trace/insights/types.js.map +1 -1
- package/models/trace/root-causes/LayoutShift.d.ts +9 -3
- package/models/trace/root-causes/LayoutShift.js +35 -15
- package/models/trace/root-causes/LayoutShift.js.map +1 -1
- package/models/trace/root-causes/RootCauses.d.ts +2 -1
- package/models/trace/root-causes/RootCauses.js +1 -0
- package/models/trace/root-causes/RootCauses.js.map +1 -1
- package/models/trace/types/Configuration.js +10 -2
- package/models/trace/types/Configuration.js.map +1 -1
- package/models/trace/types/Extensions.d.ts +62 -0
- package/models/trace/types/Extensions.js +38 -0
- package/models/trace/types/Extensions.js.map +1 -0
- package/models/trace/types/File.d.ts +13 -0
- package/models/trace/types/File.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +55 -14
- package/models/trace/types/TraceEvents.js +37 -9
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/models/trace/types/types-tsconfig.json +1 -0
- package/models/trace/types/types.d.ts +1 -0
- package/models/trace/types/types.js +1 -0
- package/models/trace/types/types.js.map +1 -1
- package/package.json +1 -1
- package/core/platform/array-utilities.d.ts +0 -66
- package/core/platform/array-utilities.js +0 -199
- package/core/platform/array-utilities.js.map +0 -1
- package/core/platform/date-utilities.d.ts +0 -2
- package/core/platform/date-utilities.js +0 -14
- package/core/platform/date-utilities.js.map +0 -1
- package/core/platform/dcheck-tsconfig.json +0 -8
- package/core/platform/dcheck.d.ts +0 -4
- package/core/platform/dcheck.js +0 -5
- package/core/platform/dom-utilities.d.ts +0 -8
- package/core/platform/dom-utilities.js +0 -109
- package/core/platform/dom-utilities.js.map +0 -1
- package/core/platform/keyboard-utilities.d.ts +0 -17
- package/core/platform/keyboard-utilities.js +0 -22
- package/core/platform/keyboard-utilities.js.map +0 -1
- package/core/platform/map-utilities.d.ts +0 -18
- package/core/platform/map-utilities.js +0 -76
- package/core/platform/map-utilities.js.map +0 -1
- package/core/platform/number-utilities.d.ts +0 -15
- package/core/platform/number-utilities.js +0 -82
- package/core/platform/number-utilities.js.map +0 -1
- package/core/platform/promise-utilities.d.ts +0 -10
- package/core/platform/promise-utilities.js +0 -18
- package/core/platform/promise-utilities.js.map +0 -1
- package/core/platform/set-utilities.d.ts +0 -2
- package/core/platform/set-utilities.js +0 -23
- package/core/platform/set-utilities.js.map +0 -1
- package/core/platform/string-utilities.d.ts +0 -71
- package/core/platform/string-utilities.js +0 -513
- package/core/platform/string-utilities.js.map +0 -1
- package/core/platform/typescript-utilities.d.ts +0 -56
- package/core/platform/typescript-utilities.js +0 -25
- package/core/platform/typescript-utilities.js.map +0 -1
- /package/core/platform/{brand.d.ts → Brand.d.ts} +0 -0
- /package/core/platform/{brand.js → Brand.js} +0 -0
- /package/core/platform/{brand.js.map → Brand.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserInteractionsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/UserInteractionsHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAI3C,2EAA2E;AAC3E,sEAAsE;AACtE,wEAAwE;AACxE,2DAA2D;AAE3D,yEAAyE;AACzE,0EAA0E;AAC1E,MAAM,SAAS,GAA8C,EAAE,CAAC;AAEhE,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,C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YAClF,uBAAuB,GAAG,gBAAgB,CAAC;SAC5C;KACF;AACH,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC;QACzB,iBAAiB,EAAE,CAAC,GAAG,iBAAiB,CAAC;QACzC,8BAA8B,EAAE,CAAC,GAAG,8BAA8B,CAAC;QACnE,uBAAuB;QACvB,yBAAyB,EAAE,IAAI,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAClE,OAAO,KAAK,CAAC,GAAG,GAAG,0BAA0B,CAAC;QAChD,CAAC,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {HandlerState} from './types.js';\n\n// This handler serves two purposes. It generates a list of events that are\n// used to show user clicks in the timeline. It is also used to gather\n// EventTimings into Interactions, which we use to show interactions and\n// highlight long interactions to the user, along with INP.\n\n// We don't need to know which process / thread these events occurred in,\n// because they are effectively global, so we just track all that we find.\nconst allEvents: Types.TraceEvents.TraceEventEventTiming[] = [];\n\nexport const LONG_INTERACTION_THRESHOLD = Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(200));\n\nexport interface UserInteractionsData {\n /** All the user events we found in the trace */\n allEvents: readonly Types.TraceEvents.TraceEventEventTiming[];\n /** All the interaction events we found in the trace that had an\n * interactionId and a duration > 0\n **/\n interactionEvents: readonly Types.TraceEvents.SyntheticInteractionPair[];\n /** If the user rapidly generates interaction events (think typing into a\n * text box), in the UI we only really want to show the user the longest\n * interaction in that set.\n * For example picture interactions like this:\n * ===[interaction A]==========\n * =[interaction B]======\n * =[interaction C]=\n *\n * These events all end at the same time, and so in this instance we only want\n * to show the first interaction A on the timeline, as that is the longest one\n * and the one the developer should be focusing on. So this array of events is\n * all the interaction events filtered down, removing any nested interactions\n * entirely.\n **/\n interactionEventsWithNoNesting: readonly Types.TraceEvents.SyntheticInteractionPair[];\n // The longest duration interaction event. Can be null if the trace has no interaction events.\n longestInteractionEvent: Readonly<Types.TraceEvents.SyntheticInteractionPair>|null;\n // All interactions that went over the interaction threshold (200ms, see https://web.dev/inp/)\n interactionsOverThreshold: Readonly<Set<Types.TraceEvents.SyntheticInteractionPair>>;\n}\n\nlet longestInteractionEvent: Types.TraceEvents.SyntheticInteractionPair|null = null;\n\nconst interactionEvents: Types.TraceEvents.SyntheticInteractionPair[] = [];\nconst interactionEventsWithNoNesting: Types.TraceEvents.SyntheticInteractionPair[] = [];\nconst eventTimingEndEventsById = new Map<string, Types.TraceEvents.TraceEventEventTimingEnd>();\nconst eventTimingStartEventsForInteractions: Types.TraceEvents.TraceEventEventTimingBegin[] = [];\nlet handlerState = HandlerState.UNINITIALIZED;\n\nexport function reset(): void {\n allEvents.length = 0;\n interactionEvents.length = 0;\n eventTimingStartEventsForInteractions.length = 0;\n eventTimingEndEventsById.clear();\n interactionEventsWithNoNesting.length = 0;\n longestInteractionEvent = null;\n handlerState = HandlerState.INITIALIZED;\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Handler is not initialized');\n }\n\n if (!Types.TraceEvents.isTraceEventEventTiming(event)) {\n return;\n }\n\n if (Types.TraceEvents.isTraceEventEventTimingEnd(event)) {\n // Store the end event; for each start event that is an interaction, we need the matching end event to calculate the duration correctly.\n eventTimingEndEventsById.set(event.id, event);\n }\n\n allEvents.push(event);\n\n // From this point on we want to find events that represent interactions.\n // These events are always start events - those are the ones that contain all\n // the metadata about the interaction.\n if (!event.args.data || !Types.TraceEvents.isTraceEventEventTimingStart(event)) {\n return;\n }\n const {duration, interactionId} = event.args.data;\n // We exclude events for the sake of interactions if:\n // 1. They have no duration.\n // 2. They have no interactionId\n // 3. They have an interactionId of 0: this indicates that it's not an\n // interaction that we care about because it hasn't had its own interactionId\n // set (0 is the default on the backend).\n // See: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/timing/responsiveness_metrics.cc;l=133;drc=40c209a9c365ebb9f16fb99dfe78c7fe768b9594\n\n if (duration < 1 || interactionId === undefined || interactionId === 0) {\n return;\n }\n\n // Store the start event. In the finalize() function we will pair this with\n // its end event and create the synthetic interaction event.\n eventTimingStartEventsForInteractions.push(event);\n}\n\n/**\n * See https://web.dev/better-responsiveness-metric/#interaction-types for the\n * table that defines these sets.\n **/\nconst pointerEventTypes = new Set([\n 'pointerdown',\n 'touchstart',\n 'pointerup',\n 'touchend',\n 'mousedown',\n 'mouseup',\n 'click',\n]);\n\nconst keyboardEventTypes = new Set([\n 'keydown',\n 'keypress',\n 'keyup',\n]);\n\nexport type InteractionCategory = 'KEYBOARD'|'POINTER'|'OTHER';\nexport function categoryOfInteraction(interaction: Types.TraceEvents.SyntheticInteractionPair): InteractionCategory {\n if (pointerEventTypes.has(interaction.type)) {\n return 'POINTER';\n }\n if (keyboardEventTypes.has(interaction.type)) {\n return 'KEYBOARD';\n }\n\n return 'OTHER';\n}\n\n/**\n * We define a set of interactions as nested where:\n * 1. Their end times align.\n * 2. The longest interaction's start time is earlier than all other\n * interactions with the same end time.\n * 3. The interactions are of the same category [each interaction is either\n * categorised as keyboard, or pointer.]\n *\n * =============A=[pointerup]=\n * ====B=[pointerdown]=\n * ===C=[pointerdown]==\n * ===D=[pointerup]===\n *\n * In this example, B, C and D are all nested and therefore should not be\n * returned from this function.\n *\n * However, in this example we would only consider B nested (under A) and D\n * nested (under C). A and C both stay because they are of different types.\n * ========A=[keydown]====\n * =======B=[keyup]=====\n * ====C=[pointerdown]=\n * =D=[pointerup]=\n **/\nexport function removeNestedInteractions(interactions: readonly Types.TraceEvents.SyntheticInteractionPair[]):\n readonly Types.TraceEvents.SyntheticInteractionPair[] {\n /**\n * Because we nest events only that are in the same category, we store the\n * longest event for a given end time by category.\n **/\n const earliestEventForEndTimePerCategory:\n Record<InteractionCategory, Map<Types.Timing.MicroSeconds, Types.TraceEvents.SyntheticInteractionPair>> = {\n POINTER: new Map(),\n KEYBOARD: new Map(),\n OTHER: new Map(),\n };\n\n function storeEventIfEarliestForCategoryAndEndTime(interaction: Types.TraceEvents.SyntheticInteractionPair): void {\n const category = categoryOfInteraction(interaction);\n const earliestEventForEndTime = earliestEventForEndTimePerCategory[category];\n const endTime = Types.Timing.MicroSeconds(interaction.ts + interaction.dur);\n\n const earliestCurrentEvent = earliestEventForEndTime.get(endTime);\n if (!earliestCurrentEvent) {\n earliestEventForEndTime.set(endTime, interaction);\n return;\n }\n if (interaction.ts < earliestCurrentEvent.ts) {\n earliestEventForEndTime.set(endTime, interaction);\n } else if (\n interaction.ts === earliestCurrentEvent.ts &&\n interaction.interactionId === earliestCurrentEvent.interactionId) {\n // We have seen in traces that the same interaction can have multiple\n // events (e.g. a 'click' and a 'pointerdown'). Often only one of these\n // events will have an event handler bound to it which caused delay on\n // the main thread, and the others will not. This leads to a situation\n // where if we pick one of the events that had no event handler, its\n // processing time (processingEnd - processingStart) will be 0, but if we\n // had picked the event that had the slow event handler, we would show\n // correctly the main thread delay due to the event handler.\n // So, if we find events with the same interactionId and the same\n // begin/end times, we pick the one with the largest (processingEnd -\n // processingStart) time in order to make sure we find the event with the\n // worst main thread delay, as that is the one the user should care\n // about.\n const currentEventProcessingTime = earliestCurrentEvent.processingEnd - earliestCurrentEvent.processingStart;\n const newEventProcessingTime = interaction.processingEnd - interaction.processingStart;\n\n // Use the new interaction if it has a longer processing time than the existing one.\n if (newEventProcessingTime > currentEventProcessingTime) {\n earliestEventForEndTime.set(endTime, interaction);\n }\n }\n\n // Maximize the processing time based on the \"children\" interactions.\n // We pick the earliest start processing time, and the latest end\n // processing time to avoid under-reporting.\n if (interaction.processingStart < earliestCurrentEvent.processingStart) {\n earliestCurrentEvent.processingStart = interaction.processingStart;\n writeSyntheticTimespans(earliestCurrentEvent);\n }\n if (interaction.processingEnd > earliestCurrentEvent.processingEnd) {\n earliestCurrentEvent.processingEnd = interaction.processingEnd;\n writeSyntheticTimespans(earliestCurrentEvent);\n }\n }\n\n for (const interaction of interactions) {\n storeEventIfEarliestForCategoryAndEndTime(interaction);\n }\n\n // Combine all the events that we have kept from all the per-category event\n // maps back into an array and sort them by timestamp.\n const keptEvents = Object.values(earliestEventForEndTimePerCategory)\n .flatMap(eventsByEndTime => Array.from(eventsByEndTime.values()));\n keptEvents.sort((eventA, eventB) => {\n return eventA.ts - eventB.ts;\n });\n return keptEvents;\n}\n\nfunction writeSyntheticTimespans(event: Types.TraceEvents.SyntheticInteractionPair): void {\n const startEvent = event.args.data.beginEvent;\n const endEvent = event.args.data.endEvent;\n\n event.inputDelay = Types.Timing.MicroSeconds(event.processingStart - startEvent.ts);\n event.mainThreadHandling = Types.Timing.MicroSeconds(event.processingEnd - event.processingStart);\n event.presentationDelay = Types.Timing.MicroSeconds(endEvent.ts - event.processingEnd);\n}\n\nexport async function finalize(): Promise<void> {\n // For each interaction start event, find the async end event by the ID, and then create the Synthetic Interaction event.\n for (const interactionStartEvent of eventTimingStartEventsForInteractions) {\n const endEvent = eventTimingEndEventsById.get(interactionStartEvent.id);\n if (!endEvent) {\n // If we cannot find an end event, bail and drop this event.\n continue;\n }\n if (!interactionStartEvent.args.data?.type || !interactionStartEvent.args.data?.interactionId) {\n // A valid interaction event that we care about has to have a type (e.g.\n // pointerdown, keyup).\n //\n // We also need to ensure it has an interactionId. We already checked\n // this in the handleEvent() function, but we do it here also to satisfy\n // TypeScript.\n continue;\n }\n\n // In the future we will add microsecond timestamps to the trace events,\n // but until then we can use the millisecond precision values that are in\n // the trace event. To adjust them to be relative to the event.ts and the\n // trace timestamps, for both processingStart and processingEnd we subtract\n // the event timestamp (NOT event.ts, but the timeStamp millisecond value\n // emitted in args.data), and then add that value to the event.ts. This\n // will give us a processingStart and processingEnd time in microseconds\n // that is relative to event.ts, and can be used when drawing boxes.\n // There is some inaccuracy here as we are converting milliseconds to microseconds, but it is good enough until the backend emits more accurate numbers.\n const processingStartRelativeToTraceTime = Types.Timing.MicroSeconds(\n Helpers.Timing.millisecondsToMicroseconds(interactionStartEvent.args.data.processingStart) -\n Helpers.Timing.millisecondsToMicroseconds(interactionStartEvent.args.data.timeStamp) +\n interactionStartEvent.ts,\n );\n\n const processingEndRelativeToTraceTime = Types.Timing.MicroSeconds(\n (Helpers.Timing.millisecondsToMicroseconds(interactionStartEvent.args.data.processingEnd) -\n Helpers.Timing.millisecondsToMicroseconds(interactionStartEvent.args.data.timeStamp)) +\n interactionStartEvent.ts);\n\n const interactionEvent: Types.TraceEvents.SyntheticInteractionPair = {\n // Use the start event to define the common fields.\n cat: interactionStartEvent.cat,\n name: interactionStartEvent.name,\n pid: interactionStartEvent.pid,\n tid: interactionStartEvent.tid,\n ph: interactionStartEvent.ph,\n processingStart: processingStartRelativeToTraceTime,\n processingEnd: processingEndRelativeToTraceTime,\n // These will be set in writeSyntheticTimespans()\n inputDelay: Types.Timing.MicroSeconds(-1),\n mainThreadHandling: Types.Timing.MicroSeconds(-1),\n presentationDelay: Types.Timing.MicroSeconds(-1),\n args: {\n data: {\n beginEvent: interactionStartEvent,\n endEvent: endEvent,\n },\n },\n ts: interactionStartEvent.ts,\n dur: Types.Timing.MicroSeconds(endEvent.ts - interactionStartEvent.ts),\n type: interactionStartEvent.args.data.type,\n interactionId: interactionStartEvent.args.data.interactionId,\n };\n writeSyntheticTimespans(interactionEvent);\n\n interactionEvents.push(interactionEvent);\n }\n\n handlerState = HandlerState.FINALIZED;\n interactionEventsWithNoNesting.push(...removeNestedInteractions(interactionEvents));\n\n // Pick the longest interactions from the set that were not nested, as we\n // know those are the set of the largest interactions.\n for (const interactionEvent of interactionEventsWithNoNesting) {\n if (!longestInteractionEvent || longestInteractionEvent.dur < interactionEvent.dur) {\n longestInteractionEvent = interactionEvent;\n }\n }\n}\n\nexport function data(): UserInteractionsData {\n return {\n allEvents: [...allEvents],\n interactionEvents: [...interactionEvents],\n interactionEventsWithNoNesting: [...interactionEventsWithNoNesting],\n longestInteractionEvent,\n interactionsOverThreshold: new Set(interactionEvents.filter(event => {\n return event.dur > LONG_INTERACTION_THRESHOLD;\n })),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UserInteractionsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/UserInteractionsHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAGzD,2EAA2E;AAC3E,sEAAsE;AACtE,wEAAwE;AACxE,2DAA2D;AAE3D,yEAAyE;AACzE,0EAA0E;AAC1E,MAAM,SAAS,GAA8C,EAAE,CAAC;AAEhE,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;AA8BpH,IAAI,uBAAuB,GAAoD,IAAI,CAAC;AAEpF,MAAM,iBAAiB,GAAiD,EAAE,CAAC;AAC3E,MAAM,8BAA8B,GAAiD,EAAE,CAAC;AACxF,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAAsD,CAAC;AAC/F,MAAM,qCAAqC,GAAmD,EAAE,CAAC;AACjG,IAAI,YAAY,qCAA6B,CAAC;AAE9C,MAAM,UAAU,KAAK;IACnB,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACrB,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7B,qCAAqC,CAAC,MAAM,GAAG,CAAC,CAAC;IACjD,wBAAwB,CAAC,KAAK,EAAE,CAAC;IACjC,8BAA8B,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1C,uBAAu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AC9D,IAAI,CAAC,uBAAuB,IAAI,uBAAuB,CAAC,GAAG,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC;YACnF,uBAAuB,GAAG,gBAAgB,CAAC;QAC7C,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,SAAS;QACT,iBAAiB;QACjB,8BAA8B;QAC9B,uBAAuB;QACvB,yBAAyB,EAAE,IAAI,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAClE,OAAO,KAAK,CAAC,GAAG,GAAG,0BAA0B,CAAC;QAChD,CAAC,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {data as metaHandlerData} from './MetaHandler.js';\nimport {HandlerState, type TraceEventHandlerName} from './types.js';\n\n// This handler serves two purposes. It generates a list of events that are\n// used to show user clicks in the timeline. It is also used to gather\n// EventTimings into Interactions, which we use to show interactions and\n// highlight long interactions to the user, along with INP.\n\n// We don't need to know which process / thread these events occurred in,\n// because they are effectively global, so we just track all that we find.\nconst allEvents: Types.TraceEvents.TraceEventEventTiming[] = [];\n\nexport const LONG_INTERACTION_THRESHOLD = Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(200));\n\nexport interface UserInteractionsData {\n /** All the user events we found in the trace */\n allEvents: readonly Types.TraceEvents.TraceEventEventTiming[];\n /** All the interaction events we found in the trace that had an\n * interactionId and a duration > 0\n **/\n interactionEvents: readonly Types.TraceEvents.SyntheticInteractionPair[];\n /** If the user rapidly generates interaction events (think typing into a\n * text box), in the UI we only really want to show the user the longest\n * interaction in that set.\n * For example picture interactions like this:\n * ===[interaction A]==========\n * =[interaction B]======\n * =[interaction C]=\n *\n * These events all end at the same time, and so in this instance we only want\n * to show the first interaction A on the timeline, as that is the longest one\n * and the one the developer should be focusing on. So this array of events is\n * all the interaction events filtered down, removing any nested interactions\n * entirely.\n **/\n interactionEventsWithNoNesting: readonly Types.TraceEvents.SyntheticInteractionPair[];\n // The longest duration interaction event. Can be null if the trace has no interaction events.\n longestInteractionEvent: Readonly<Types.TraceEvents.SyntheticInteractionPair>|null;\n // All interactions that went over the interaction threshold (200ms, see https://web.dev/inp/)\n interactionsOverThreshold: Readonly<Set<Types.TraceEvents.SyntheticInteractionPair>>;\n}\n\nlet longestInteractionEvent: Types.TraceEvents.SyntheticInteractionPair|null = null;\n\nconst interactionEvents: Types.TraceEvents.SyntheticInteractionPair[] = [];\nconst interactionEventsWithNoNesting: Types.TraceEvents.SyntheticInteractionPair[] = [];\nconst eventTimingEndEventsById = new Map<string, Types.TraceEvents.TraceEventEventTimingEnd>();\nconst eventTimingStartEventsForInteractions: Types.TraceEvents.TraceEventEventTimingBegin[] = [];\nlet handlerState = HandlerState.UNINITIALIZED;\n\nexport function reset(): void {\n allEvents.length = 0;\n interactionEvents.length = 0;\n eventTimingStartEventsForInteractions.length = 0;\n eventTimingEndEventsById.clear();\n interactionEventsWithNoNesting.length = 0;\n longestInteractionEvent = null;\n handlerState = HandlerState.INITIALIZED;\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Handler is not initialized');\n }\n\n if (!Types.TraceEvents.isTraceEventEventTiming(event)) {\n return;\n }\n\n if (Types.TraceEvents.isTraceEventEventTimingEnd(event)) {\n // Store the end event; for each start event that is an interaction, we need the matching end event to calculate the duration correctly.\n eventTimingEndEventsById.set(event.id, event);\n }\n\n allEvents.push(event);\n\n // From this point on we want to find events that represent interactions.\n // These events are always start events - those are the ones that contain all\n // the metadata about the interaction.\n if (!event.args.data || !Types.TraceEvents.isTraceEventEventTimingStart(event)) {\n return;\n }\n const {duration, interactionId} = event.args.data;\n // We exclude events for the sake of interactions if:\n // 1. They have no duration.\n // 2. They have no interactionId\n // 3. They have an interactionId of 0: this indicates that it's not an\n // interaction that we care about because it hasn't had its own interactionId\n // set (0 is the default on the backend).\n // See: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/timing/responsiveness_metrics.cc;l=133;drc=40c209a9c365ebb9f16fb99dfe78c7fe768b9594\n\n if (duration < 1 || interactionId === undefined || interactionId === 0) {\n return;\n }\n\n // Store the start event. In the finalize() function we will pair this with\n // its end event and create the synthetic interaction event.\n eventTimingStartEventsForInteractions.push(event);\n}\n\n/**\n * See https://web.dev/better-responsiveness-metric/#interaction-types for the\n * table that defines these sets.\n **/\nconst pointerEventTypes = new Set([\n 'pointerdown',\n 'touchstart',\n 'pointerup',\n 'touchend',\n 'mousedown',\n 'mouseup',\n 'click',\n]);\n\nconst keyboardEventTypes = new Set([\n 'keydown',\n 'keypress',\n 'keyup',\n]);\n\nexport type InteractionCategory = 'KEYBOARD'|'POINTER'|'OTHER';\nexport function categoryOfInteraction(interaction: Types.TraceEvents.SyntheticInteractionPair): InteractionCategory {\n if (pointerEventTypes.has(interaction.type)) {\n return 'POINTER';\n }\n if (keyboardEventTypes.has(interaction.type)) {\n return 'KEYBOARD';\n }\n\n return 'OTHER';\n}\n\n/**\n * We define a set of interactions as nested where:\n * 1. Their end times align.\n * 2. The longest interaction's start time is earlier than all other\n * interactions with the same end time.\n * 3. The interactions are of the same category [each interaction is either\n * categorised as keyboard, or pointer.]\n *\n * =============A=[pointerup]=\n * ====B=[pointerdown]=\n * ===C=[pointerdown]==\n * ===D=[pointerup]===\n *\n * In this example, B, C and D are all nested and therefore should not be\n * returned from this function.\n *\n * However, in this example we would only consider B nested (under A) and D\n * nested (under C). A and C both stay because they are of different types.\n * ========A=[keydown]====\n * =======B=[keyup]=====\n * ====C=[pointerdown]=\n * =D=[pointerup]=\n **/\nexport function removeNestedInteractions(interactions: readonly Types.TraceEvents.SyntheticInteractionPair[]):\n readonly Types.TraceEvents.SyntheticInteractionPair[] {\n /**\n * Because we nest events only that are in the same category, we store the\n * longest event for a given end time by category.\n **/\n const earliestEventForEndTimePerCategory:\n Record<InteractionCategory, Map<Types.Timing.MicroSeconds, Types.TraceEvents.SyntheticInteractionPair>> = {\n POINTER: new Map(),\n KEYBOARD: new Map(),\n OTHER: new Map(),\n };\n\n function storeEventIfEarliestForCategoryAndEndTime(interaction: Types.TraceEvents.SyntheticInteractionPair): void {\n const category = categoryOfInteraction(interaction);\n const earliestEventForEndTime = earliestEventForEndTimePerCategory[category];\n const endTime = Types.Timing.MicroSeconds(interaction.ts + interaction.dur);\n\n const earliestCurrentEvent = earliestEventForEndTime.get(endTime);\n if (!earliestCurrentEvent) {\n earliestEventForEndTime.set(endTime, interaction);\n return;\n }\n if (interaction.ts < earliestCurrentEvent.ts) {\n earliestEventForEndTime.set(endTime, interaction);\n } else if (\n interaction.ts === earliestCurrentEvent.ts &&\n interaction.interactionId === earliestCurrentEvent.interactionId) {\n // We have seen in traces that the same interaction can have multiple\n // events (e.g. a 'click' and a 'pointerdown'). Often only one of these\n // events will have an event handler bound to it which caused delay on\n // the main thread, and the others will not. This leads to a situation\n // where if we pick one of the events that had no event handler, its\n // processing duration (processingEnd - processingStart) will be 0, but if we\n // had picked the event that had the slow event handler, we would show\n // correctly the main thread delay due to the event handler.\n // So, if we find events with the same interactionId and the same\n // begin/end times, we pick the one with the largest (processingEnd -\n // processingStart) time in order to make sure we find the event with the\n // worst main thread delay, as that is the one the user should care\n // about.\n const currentProcessingDuration = earliestCurrentEvent.processingEnd - earliestCurrentEvent.processingStart;\n const newProcessingDuration = interaction.processingEnd - interaction.processingStart;\n\n // Use the new interaction if it has a longer processing duration than the existing one.\n if (newProcessingDuration > currentProcessingDuration) {\n earliestEventForEndTime.set(endTime, interaction);\n }\n }\n\n // Maximize the processing duration based on the \"children\" interactions.\n // We pick the earliest start processing duration, and the latest end\n // processing duration to avoid under-reporting.\n if (interaction.processingStart < earliestCurrentEvent.processingStart) {\n earliestCurrentEvent.processingStart = interaction.processingStart;\n writeSyntheticTimespans(earliestCurrentEvent);\n }\n if (interaction.processingEnd > earliestCurrentEvent.processingEnd) {\n earliestCurrentEvent.processingEnd = interaction.processingEnd;\n writeSyntheticTimespans(earliestCurrentEvent);\n }\n }\n\n for (const interaction of interactions) {\n storeEventIfEarliestForCategoryAndEndTime(interaction);\n }\n\n // Combine all the events that we have kept from all the per-category event\n // maps back into an array and sort them by timestamp.\n const keptEvents = Object.values(earliestEventForEndTimePerCategory)\n .flatMap(eventsByEndTime => Array.from(eventsByEndTime.values()));\n keptEvents.sort((eventA, eventB) => {\n return eventA.ts - eventB.ts;\n });\n return keptEvents;\n}\n\nfunction writeSyntheticTimespans(event: Types.TraceEvents.SyntheticInteractionPair): void {\n const startEvent = event.args.data.beginEvent;\n const endEvent = event.args.data.endEvent;\n\n event.inputDelay = Types.Timing.MicroSeconds(event.processingStart - startEvent.ts);\n event.mainThreadHandling = Types.Timing.MicroSeconds(event.processingEnd - event.processingStart);\n event.presentationDelay = Types.Timing.MicroSeconds(endEvent.ts - event.processingEnd);\n}\n\nexport async function finalize(): Promise<void> {\n const {navigationsByFrameId} = metaHandlerData();\n\n // For each interaction start event, find the async end event by the ID, and then create the Synthetic Interaction event.\n for (const interactionStartEvent of eventTimingStartEventsForInteractions) {\n const endEvent = eventTimingEndEventsById.get(interactionStartEvent.id);\n if (!endEvent) {\n // If we cannot find an end event, bail and drop this event.\n continue;\n }\n if (!interactionStartEvent.args.data?.type || !interactionStartEvent.args.data?.interactionId) {\n // A valid interaction event that we care about has to have a type (e.g.\n // pointerdown, keyup).\n //\n // We also need to ensure it has an interactionId. We already checked\n // this in the handleEvent() function, but we do it here also to satisfy\n // TypeScript.\n continue;\n }\n\n // In the future we will add microsecond timestamps to the trace events,\n // but until then we can use the millisecond precision values that are in\n // the trace event. To adjust them to be relative to the event.ts and the\n // trace timestamps, for both processingStart and processingEnd we subtract\n // the event timestamp (NOT event.ts, but the timeStamp millisecond value\n // emitted in args.data), and then add that value to the event.ts. This\n // will give us a processingStart and processingEnd time in microseconds\n // that is relative to event.ts, and can be used when drawing boxes.\n // There is some inaccuracy here as we are converting milliseconds to microseconds, but it is good enough until the backend emits more accurate numbers.\n const processingStartRelativeToTraceTime = Types.Timing.MicroSeconds(\n Helpers.Timing.millisecondsToMicroseconds(interactionStartEvent.args.data.processingStart) -\n Helpers.Timing.millisecondsToMicroseconds(interactionStartEvent.args.data.timeStamp) +\n interactionStartEvent.ts,\n );\n\n const processingEndRelativeToTraceTime = Types.Timing.MicroSeconds(\n (Helpers.Timing.millisecondsToMicroseconds(interactionStartEvent.args.data.processingEnd) -\n Helpers.Timing.millisecondsToMicroseconds(interactionStartEvent.args.data.timeStamp)) +\n interactionStartEvent.ts);\n\n const frameId = interactionStartEvent.args.frame ?? interactionStartEvent.args.data.frame;\n const navigation = Helpers.Trace.getNavigationForTraceEvent(interactionStartEvent, frameId, navigationsByFrameId);\n const navigationId = navigation?.args.data?.navigationId;\n\n const interactionEvent: Types.TraceEvents.SyntheticInteractionPair = {\n // Use the start event to define the common fields.\n cat: interactionStartEvent.cat,\n name: interactionStartEvent.name,\n pid: interactionStartEvent.pid,\n tid: interactionStartEvent.tid,\n ph: interactionStartEvent.ph,\n processingStart: processingStartRelativeToTraceTime,\n processingEnd: processingEndRelativeToTraceTime,\n // These will be set in writeSyntheticTimespans()\n inputDelay: Types.Timing.MicroSeconds(-1),\n mainThreadHandling: Types.Timing.MicroSeconds(-1),\n presentationDelay: Types.Timing.MicroSeconds(-1),\n args: {\n data: {\n beginEvent: interactionStartEvent,\n endEvent: endEvent,\n frame: frameId,\n navigationId,\n },\n },\n ts: interactionStartEvent.ts,\n dur: Types.Timing.MicroSeconds(endEvent.ts - interactionStartEvent.ts),\n type: interactionStartEvent.args.data.type,\n interactionId: interactionStartEvent.args.data.interactionId,\n };\n writeSyntheticTimespans(interactionEvent);\n\n interactionEvents.push(interactionEvent);\n }\n\n handlerState = HandlerState.FINALIZED;\n interactionEventsWithNoNesting.push(...removeNestedInteractions(interactionEvents));\n\n // Pick the longest interactions from the set that were not nested, as we\n // know those are the set of the largest interactions.\n for (const interactionEvent of interactionEventsWithNoNesting) {\n if (!longestInteractionEvent || longestInteractionEvent.dur < interactionEvent.dur) {\n longestInteractionEvent = interactionEvent;\n }\n }\n}\n\nexport function data(): UserInteractionsData {\n return {\n allEvents,\n interactionEvents,\n interactionEventsWithNoNesting,\n longestInteractionEvent,\n interactionsOverThreshold: new Set(interactionEvents.filter(event => {\n return event.dur > LONG_INTERACTION_THRESHOLD;\n })),\n };\n}\n\nexport function deps(): TraceEventHandlerName[] {\n return ['Meta'];\n}\n"]}
|
|
@@ -101,6 +101,7 @@ export function data() {
|
|
|
101
101
|
return {
|
|
102
102
|
performanceMeasures: syntheticEvents.filter(e => e.cat === 'blink.user_timing'),
|
|
103
103
|
consoleTimings: syntheticEvents.filter(e => e.cat === 'blink.console'),
|
|
104
|
+
// TODO(crbug/41484172): UserTimingsHandler.test.ts fails if this is not copied.
|
|
104
105
|
performanceMarks: [...performanceMarkEvents],
|
|
105
106
|
timestampEvents: [...timestampEvents],
|
|
106
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserTimingsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/UserTimingsHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAI3C;;;;IAII;AACJ,IAAI,eAAe,GAAsF,EAAE,CAAC;AAC5G,MAAM,wBAAwB,GAAqD,EAAE,CAAC;AACtF,MAAM,qBAAqB,GAAkD,EAAE,CAAC;AAEhF,MAAM,cAAc,GAAgG,EAAE,CAAC;AAEvH,MAAM,eAAe,GAA4C,EAAE,CAAC;AAyBpE,IAAI,YAAY,qCAA6B,CAAC;AAE9C,MAAM,UAAU,KAAK;IACnB,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,wBAAwB,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,qBAAqB,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,YAAY,mCAA2B,CAAC;AAC1C,CAAC;AAED,MAAM,mBAAmB,GAAG;IAC1B,aAAa;IACb,eAAe;IACf,aAAa;IACb,YAAY;IACZ,mBAAmB;IACnB,iBAAiB;IACjB,cAAc;IACd,YAAY;IACZ,uBAAuB;IACvB,cAAc;IACd,eAAe;IACf,aAAa;CACd,CAAC;AACF,MAAM,cAAc,GAAG;IACrB,iBAAiB;IACjB,kBAAkB;IAClB,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,YAAY;IACZ,qBAAqB;IACrB,mBAAmB;IACnB,iBAAiB;IACjB,cAAc;IACd,YAAY;IACZ,uBAAuB;IACvB,cAAc;IACd,eAAe;IACf,aAAa;IACb,YAAY;IACZ,gBAAgB;IAChB,4BAA4B;IAC5B,0BAA0B;IAC1B,aAAa;IACb,gBAAgB;IAChB,cAAc;CACf,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,KAAuC;IACjE,IAAI,YAAY,qCAA6B,EAAE;
|
|
1
|
+
{"version":3,"file":"UserTimingsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/UserTimingsHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAI3C;;;;IAII;AACJ,IAAI,eAAe,GAAsF,EAAE,CAAC;AAC5G,MAAM,wBAAwB,GAAqD,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,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,eAAe,CACnB;QAClD,gFAAgF;QAChF,gBAAgB,EAAE,CAAC,GAAG,qBAAqB,CAAC;QAC5C,eAAe,EAAE,CAAC,GAAG,eAAe,CAAC;KACtC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {HandlerState} from './types.js';\n\n/**\n * IMPORTANT!\n * See UserTimings.md in this directory for some handy documentation on\n * UserTimings and the trace events we parse currently.\n **/\nlet syntheticEvents: Types.TraceEvents.SyntheticEventPair<Types.TraceEvents.TraceEventPairableAsync>[] = [];\nconst performanceMeasureEvents: Types.TraceEvents.TraceEventPerformanceMeasure[] = [];\nconst performanceMarkEvents: Types.TraceEvents.TraceEventPerformanceMark[] = [];\n\nconst consoleTimings: (Types.TraceEvents.TraceEventConsoleTimeBegin|Types.TraceEvents.TraceEventConsoleTimeEnd)[] = [];\n\nconst timestampEvents: Types.TraceEvents.TraceEventTimeStamp[] = [];\n\nexport interface UserTimingsData {\n /**\n * Events triggered with the performance.measure() API.\n * https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure\n */\n performanceMeasures: readonly Types.TraceEvents.SyntheticUserTimingPair[];\n /**\n * Events triggered with the performance.mark() API.\n * https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark\n */\n performanceMarks: readonly Types.TraceEvents.TraceEventPerformanceMark[];\n /**\n * Events triggered with the console.time(), console.timeEnd() and\n * console.timeLog() API.\n * https://developer.mozilla.org/en-US/docs/Web/API/console/time\n */\n consoleTimings: readonly Types.TraceEvents.SyntheticConsoleTimingPair[];\n /**\n * Events triggered with the console.timeStamp() API\n * https://developer.mozilla.org/en-US/docs/Web/API/console/timeStamp\n */\n timestampEvents: readonly Types.TraceEvents.TraceEventTimeStamp[];\n}\nlet handlerState = HandlerState.UNINITIALIZED;\n\nexport function reset(): void {\n syntheticEvents.length = 0;\n performanceMeasureEvents.length = 0;\n performanceMarkEvents.length = 0;\n consoleTimings.length = 0;\n timestampEvents.length = 0;\n handlerState = HandlerState.INITIALIZED;\n}\n\nconst resourceTimingNames = [\n 'workerStart',\n 'redirectStart',\n 'redirectEnd',\n 'fetchStart',\n 'domainLookupStart',\n 'domainLookupEnd',\n 'connectStart',\n 'connectEnd',\n 'secureConnectionStart',\n 'requestStart',\n 'responseStart',\n 'responseEnd',\n];\nconst navTimingNames = [\n 'navigationStart',\n 'unloadEventStart',\n 'unloadEventEnd',\n 'redirectStart',\n 'redirectEnd',\n 'fetchStart',\n 'commitNavigationEnd',\n 'domainLookupStart',\n 'domainLookupEnd',\n 'connectStart',\n 'connectEnd',\n 'secureConnectionStart',\n 'requestStart',\n 'responseStart',\n 'responseEnd',\n 'domLoading',\n 'domInteractive',\n 'domContentLoadedEventStart',\n 'domContentLoadedEventEnd',\n 'domComplete',\n 'loadEventStart',\n 'loadEventEnd',\n];\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('UserTimings handler is not initialized');\n }\n\n // These are events dispatched under the blink.user_timing category\n // but that the user didn't add. Filter them out so that they do not\n // Appear in the timings track (they still appear in the main thread\n // flame chart).\n const ignoredNames = [...resourceTimingNames, ...navTimingNames];\n if (ignoredNames.includes(event.name)) {\n return;\n }\n\n if (Types.TraceEvents.isTraceEventPerformanceMeasure(event)) {\n performanceMeasureEvents.push(event);\n return;\n }\n if (Types.TraceEvents.isTraceEventPerformanceMark(event)) {\n performanceMarkEvents.push(event);\n }\n if (Types.TraceEvents.isTraceEventConsoleTime(event)) {\n consoleTimings.push(event);\n }\n if (Types.TraceEvents.isTraceEventTimeStamp(event)) {\n timestampEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('UserTimings handler is not initialized');\n }\n\n const asyncEvents = [...performanceMeasureEvents, ...consoleTimings];\n syntheticEvents = Helpers.Trace.createMatchedSortedSyntheticEvents(asyncEvents);\n handlerState = HandlerState.FINALIZED;\n}\n\nexport function data(): UserTimingsData {\n if (handlerState !== HandlerState.FINALIZED) {\n throw new Error('UserTimings handler is not finalized');\n }\n\n return {\n performanceMeasures: syntheticEvents.filter(e => e.cat === 'blink.user_timing') as\n Types.TraceEvents.SyntheticUserTimingPair[],\n consoleTimings: syntheticEvents.filter(e => e.cat === 'blink.console') as\n Types.TraceEvents.SyntheticConsoleTimingPair[],\n // TODO(crbug/41484172): UserTimingsHandler.test.ts fails if this is not copied.\n performanceMarks: [...performanceMarkEvents],\n timestampEvents: [...timestampEvents],\n };\n}\n"]}
|
|
@@ -118,8 +118,8 @@ export async function finalize() {
|
|
|
118
118
|
}
|
|
119
119
|
export function data() {
|
|
120
120
|
return {
|
|
121
|
-
perEvent:
|
|
122
|
-
perWarning:
|
|
121
|
+
perEvent: warningsPerEvent,
|
|
122
|
+
perWarning: eventsPerWarning,
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
//# sourceMappingURL=WarningsHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WarningsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/WarningsHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAC,IAAI,IAAI,2BAA2B,EAAC,MAAM,8BAA8B,CAAC;AAYjF,MAAM,gBAAgB,GAA6B,IAAI,GAAG,EAAE,CAAC;AAC7D,MAAM,gBAAgB,GAA+B,IAAI,GAAG,EA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,EAAE,GAAG,QAAQ,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC;QAChE,KAAK,CAAC,GAAG,EAAE,CAAC;QACZ,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,wEAAwE;IACxE,wEAAwE;IACxE,yEAAyE;IACzE,4EAA4E;IAC5E,6DAA6D;IAC7D,MAAM,gBAAgB,GAAG,2BAA2B,EAAE,CAAC,yBAAyB,CAAC;IACjF,KAAK,MAAM,WAAW,IAAI,gBAAgB,EAAE,CAAC;QAC3C,YAAY,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,QAAQ,EAAE,gBAAgB;QAC1B,UAAU,EAAE,gBAAgB;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {type TraceEventHandlerName} from './types.js';\nimport {data as userInteractionsHandlerData} from './UserInteractionsHandler.js';\n\nexport interface WarningsData {\n // Tracks warnings keyed by the event.\n perEvent: Map<Types.TraceEvents.TraceEventData, Warning[]>;\n // The same data in reverse: for each type of warning, track the events.\n // Useful if we need to enumerate events by type of issue\n perWarning: Map<Warning, Types.TraceEvents.TraceEventData[]>;\n}\n\nexport type Warning = 'LONG_TASK'|'IDLE_CALLBACK_OVER_TIME'|'FORCED_REFLOW'|'LONG_INTERACTION';\n\nconst warningsPerEvent: WarningsData['perEvent'] = new Map();\nconst eventsPerWarning: WarningsData['perWarning'] = new Map();\n\n/**\n * Tracks the stack formed by nested trace events up to a given point\n */\nconst allEventsStack: Types.TraceEvents.TraceEventData[] = [];\n/**\n * Tracks the stack formed by JS invocation trace events up to a given point.\n * F.e. FunctionCall, EvaluateScript, V8Execute.\n * Not to be confused with ProfileCalls.\n */\nconst jsInvokeStack: Types.TraceEvents.TraceEventData[] = [];\n/**\n * Tracks reflow events in a task.\n */\nconst taskReflowEvents: Types.TraceEvents.TraceEventData[] = [];\n\nexport const FORCED_REFLOW_THRESHOLD = Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(30));\n\nexport const LONG_MAIN_THREAD_TASK_THRESHOLD = Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(50));\n\nexport function reset(): void {\n warningsPerEvent.clear();\n eventsPerWarning.clear();\n allEventsStack.length = 0;\n jsInvokeStack.length = 0;\n taskReflowEvents.length = 0;\n}\n\nfunction storeWarning(event: Types.TraceEvents.TraceEventData, warning: Warning): void {\n const existingWarnings = Platform.MapUtilities.getWithDefault(warningsPerEvent, event, () => []);\n existingWarnings.push(warning);\n warningsPerEvent.set(event, existingWarnings);\n\n const existingEvents = Platform.MapUtilities.getWithDefault(eventsPerWarning, warning, () => []);\n existingEvents.push(event);\n eventsPerWarning.set(warning, existingEvents);\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n processForcedReflowWarning(event);\n if (event.name === Types.TraceEvents.KnownEventName.RunTask) {\n const {duration} = Helpers.Timing.eventTimingsMicroSeconds(event);\n if (duration > LONG_MAIN_THREAD_TASK_THRESHOLD) {\n storeWarning(event, 'LONG_TASK');\n }\n return;\n }\n\n if (Types.TraceEvents.isTraceEventFireIdleCallback(event)) {\n const {duration} = Helpers.Timing.eventTimingsMilliSeconds(event);\n if (duration > event.args.data.allottedMilliseconds) {\n storeWarning(event, 'IDLE_CALLBACK_OVER_TIME');\n }\n return;\n }\n}\n\n/**\n * Reflows* are added a warning to if:\n * 1. They are forced/sync, meaning they are invoked by JS and finish\n * during the Script execution.\n * 2. Their duration exceeds a threshold.\n * - *Reflow: The style recalculation and layout steps in a render task.\n */\nfunction processForcedReflowWarning(event: Types.TraceEvents.TraceEventData): void {\n // Update the event and the JS invocation stacks.\n accomodateEventInStack(event, allEventsStack);\n accomodateEventInStack(event, jsInvokeStack, /* pushEventToStack */ Types.TraceEvents.isJSInvocationEvent(event));\n if (jsInvokeStack.length) {\n // Current event falls inside a JS call.\n if (event.name === Types.TraceEvents.KnownEventName.Layout ||\n event.name === Types.TraceEvents.KnownEventName.RecalculateStyles ||\n event.name === Types.TraceEvents.KnownEventName.UpdateLayoutTree) {\n // A forced reflow happened. However we need to check if\n // the threshold is surpassed to add a warning. Accumulate the\n // event to check for this after the current Task is over.\n taskReflowEvents.push(event);\n return;\n }\n }\n if (allEventsStack.length === 1) {\n // We hit a new task. Check if the forced reflows in the previous\n // task exceeded the threshold and add a warning if so.\n const totalTime = taskReflowEvents.reduce((time, event) => time + (event.dur || 0), 0);\n if (totalTime >= FORCED_REFLOW_THRESHOLD) {\n taskReflowEvents.forEach(reflowEvent => storeWarning(reflowEvent, 'FORCED_REFLOW'));\n }\n taskReflowEvents.length = 0;\n }\n}\n\n/**\n * Updates a given trace event stack given a new event.\n */\nfunction accomodateEventInStack(\n event: Types.TraceEvents.TraceEventData, stack: Types.TraceEvents.TraceEventData[], pushEventToStack = true): void {\n let nextItem = stack.at(-1);\n while (nextItem && event.ts > nextItem.ts + (nextItem.dur || 0)) {\n stack.pop();\n nextItem = stack.at(-1);\n }\n if (!pushEventToStack) {\n return;\n }\n stack.push(event);\n}\n\nexport function deps(): TraceEventHandlerName[] {\n return ['UserInteractions'];\n}\n\nexport async function finalize(): Promise<void> {\n // These events do exist on the UserInteractionsHandler, but we also put\n // them into the WarningsHandler so that the warnings handler can be the\n // source of truth and the way to look up all warnings for a given event.\n // Otherwise, we would have to look up warnings across multiple handlers for\n // a given event, which will start to get messy very quickly.\n const longInteractions = userInteractionsHandlerData().interactionsOverThreshold;\n for (const interaction of longInteractions) {\n storeWarning(interaction, 'LONG_INTERACTION');\n }\n}\n\nexport function data(): WarningsData {\n return {\n perEvent: warningsPerEvent,\n perWarning: eventsPerWarning,\n };\n}\n"]}
|
|
@@ -44,9 +44,9 @@ export function data() {
|
|
|
44
44
|
throw new Error('Workers Handler is not finalized');
|
|
45
45
|
}
|
|
46
46
|
return {
|
|
47
|
-
workerSessionIdEvents:
|
|
48
|
-
workerIdByThread
|
|
49
|
-
workerURLById
|
|
47
|
+
workerSessionIdEvents: sessionIdEvents,
|
|
48
|
+
workerIdByThread,
|
|
49
|
+
workerURLById,
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
//# sourceMappingURL=WorkersHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkersHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/WorkersHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAS3C,IAAI,YAAY,qCAA6B,CAAC;AAE9C,MAAM,eAAe,GAA4D,EAAE,CAAC;AACpF,MAAM,gBAAgB,GAAgE,IAAI,GAAG,EAAE,CAAC;AAChG,MAAM,aAAa,GAA4C,IAAI,GAAG,EAAE,CAAC;AAEzE,MAAM,UAAU,UAAU;IACxB,IAAI,YAAY,uCAA+B,EAAE;
|
|
1
|
+
{"version":3,"file":"WorkersHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/WorkersHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,KAAK,MAAM,mBAAm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AC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrF,CAAC;IACD,YAAY,iCAAyB,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,IAAI,YAAY,mCAA2B,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO;QACL,qBAAqB,EAAE,eAAe;QACtC,gBAAgB;QAChB,aAAa;KACd,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Types from '../types/types.js';\n\nimport {HandlerState} from './types.js';\n\nexport interface WorkersData {\n workerSessionIdEvents: readonly Types.TraceEvents.TraceEventTracingSessionIdForWorker[];\n workerIdByThread: Map<Types.TraceEvents.ThreadID, Types.TraceEvents.WorkerId>;\n workerURLById: Map<Types.TraceEvents.WorkerId, string>;\n}\nlet handlerState = HandlerState.UNINITIALIZED;\n\nconst sessionIdEvents: Types.TraceEvents.TraceEventTracingSessionIdForWorker[] = [];\nconst workerIdByThread: Map<Types.TraceEvents.ThreadID, Types.TraceEvents.WorkerId> = new Map();\nconst workerURLById: Map<Types.TraceEvents.WorkerId, string> = new Map();\n\nexport function initialize(): void {\n if (handlerState !== HandlerState.UNINITIALIZED) {\n throw new Error('Workers Handler was not reset');\n }\n\n handlerState = HandlerState.INITIALIZED;\n}\n\nexport function reset(): void {\n sessionIdEvents.length = 0;\n workerIdByThread.clear();\n workerURLById.clear();\n handlerState = HandlerState.UNINITIALIZED;\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Workers Handler is not initialized');\n }\n if (Types.TraceEvents.isTraceEventTracingSessionIdForWorker(event)) {\n sessionIdEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Handler is not initialized');\n }\n for (const sessionIdEvent of sessionIdEvents) {\n if (!sessionIdEvent.args.data) {\n continue;\n }\n workerIdByThread.set(sessionIdEvent.args.data.workerThreadId, sessionIdEvent.args.data.workerId);\n workerURLById.set(sessionIdEvent.args.data.workerId, sessionIdEvent.args.data.url);\n }\n handlerState = HandlerState.FINALIZED;\n}\n\nexport function data(): WorkersData {\n if (handlerState !== HandlerState.FINALIZED) {\n throw new Error('Workers Handler is not finalized');\n }\n\n return {\n workerSessionIdEvents: sessionIdEvents,\n workerIdByThread,\n workerURLById,\n };\n}\n"]}
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"files": [
|
|
32
32
|
"../../../../../../../front_end/models/trace/handlers/AnimationHandler.ts",
|
|
33
33
|
"../../../../../../../front_end/models/trace/handlers/AuctionWorkletsHandler.ts",
|
|
34
|
+
"../../../../../../../front_end/models/trace/handlers/ExtensionTraceDataHandler.ts",
|
|
34
35
|
"../../../../../../../front_end/models/trace/handlers/FramesHandler.ts",
|
|
35
36
|
"../../../../../../../front_end/models/trace/handlers/GPUHandler.ts",
|
|
36
37
|
"../../../../../../../front_end/models/trace/handlers/InitiatorsHandler.ts",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AA0DpD;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAA8C;IACtF,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AA0DpD;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAA8C;IACtF,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACrD,IAAI,WAAW,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YAClC,gBAAgB,GAAG,IAAI,CAAC;YACxB,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO,CAAC,gBAAgB,CAAC;AAC3B,CAAC","sourcesContent":["\n// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\nimport type * as Types from './../types/types.js';\nimport * as ModelHandlers from './ModelHandlers.js';\n\nexport interface TraceEventHandler {\n reset(): void;\n initialize?(freshRecording?: boolean): void;\n handleEvent(data: {}): void;\n finalize?(): Promise<void>;\n data(): unknown;\n deps?(): TraceEventHandlerName[];\n handleUserConfig?(config: Types.Configuration.Configuration): void;\n}\nexport type TraceEventHandlerName = keyof typeof ModelHandlers;\n\n// This type maps TraceEventHandler names to the return type of their data\n// function. So, for example, if we are given an object with a key of 'foo'\n// and a value which is a TraceHandler containing a data() function that\n// returns a string, this type will be { foo: string }.\n//\n// This allows us to model the behavior of the TraceProcessor in the model,\n// which takes an object with TraceEventHandlers as part of its config, and\n// which ultimately returns an object keyed off the names of the\n// TraceEventHandlers, and with values that are derived from each\n// TraceEventHandler's data function.\n//\n// So, concretely, we provide a TraceEventHandler for calculating the #time\n// bounds of a trace called TraceBounds, whose data() function returns a\n// TraceWindow. The HandlerData, therefore, would determine that the\n// TraceProcessor would contain a key called 'TraceBounds' whose value is\n// a TraceWindow.\nexport type EnabledHandlerDataWithMeta<T extends {[key: string]: TraceEventHandler}> = {\n // We allow the user to configure which handlers are created by passing them\n // in when constructing a model instance. However, we then ensure that the\n // Meta handler is added to that, as the Model relies on some of the data\n // from the Meta handler when creating the file. Therefore, this type\n // explicitly defines that the Meta data is present, before then extending it\n // with the index type to represent all the other handlers.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Meta: Readonly<ReturnType<typeof ModelHandlers['Meta']['data']>>,\n}&{\n // For every key in the object, look up the TraceEventHandler's data function\n // and use its return type as the value for the object.\n [K in keyof T]: Readonly<ReturnType<T[K]['data']>>;\n};\n\nexport type HandlersWithMeta<T extends {[key: string]: TraceEventHandler}> = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Meta: typeof ModelHandlers.Meta,\n}&{\n [K in keyof T]: T[K];\n};\n\n// Represents the final parsed data from all of the handlers. Note that because\n// we are currently in the middle of the migration of data engines, not all the\n// handlers are enabled. Therefore for now you should use the type defined in\n// models/trace/handlers/Migration.ts, `PartialTraceData`, which\n// represents the final parsed data for only the enabled handlers.\nexport type TraceParseData = Readonly<EnabledHandlerDataWithMeta<typeof ModelHandlers>>;\n\n/**\n * Because you can run the trace engine with a subset of handlers enabled,\n * there can be times when you need to confirm if the trace contains all\n * handlers or not, because some parts of the engine expect to be given all\n * the handlers.\n */\nexport function handlerDataHasAllHandlers(data: Readonly<EnabledHandlerDataWithMeta<{}>>): data is TraceParseData {\n let isMissingHandler = false;\n for (const handlerName of Object.keys(ModelHandlers)) {\n if (handlerName in data === false) {\n isMissingHandler = true;\n break;\n }\n }\n return !isMissingHandler;\n}\n\ntype DeepWriteable<T> = {\n -readonly[P in keyof T]: DeepWriteable<T[P]>\n};\nexport type TraceParseDataMutable = DeepWriteable<TraceParseData>;\n\nexport type Handlers = typeof ModelHandlers;\n\nexport const enum HandlerState {\n UNINITIALIZED = 1,\n INITIALIZED = 2,\n FINALIZED = 3,\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type * as Types from '../types/types.js';
|
|
2
|
+
export declare function buildTrackDataFromExtensionEntries(extensionEntries: Types.Extensions.SyntheticExtensionFlameChartEntry[], extensionTrackData: Types.Extensions.ExtensionTrackData[]): Types.Extensions.ExtensionTrackData[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright 2024 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
import * as Platform from '../../../core/platform/platform.js';
|
|
5
|
+
import { sortTraceEventsInPlace } from './Trace.js';
|
|
6
|
+
export function buildTrackDataFromExtensionEntries(extensionEntries, extensionTrackData) {
|
|
7
|
+
const dataByTrack = new Map();
|
|
8
|
+
for (const entry of extensionEntries) {
|
|
9
|
+
const trackData = Platform.MapUtilities.getWithDefault(dataByTrack, `${entry.args.metadata.extensionName}.${entry.args.track}`, () => ({
|
|
10
|
+
name: entry.args.track,
|
|
11
|
+
extensionName: entry.args.metadata.extensionName,
|
|
12
|
+
flameChartEntries: [],
|
|
13
|
+
}));
|
|
14
|
+
trackData.flameChartEntries.push(entry);
|
|
15
|
+
}
|
|
16
|
+
for (const trackData of dataByTrack.values()) {
|
|
17
|
+
sortTraceEventsInPlace(trackData.flameChartEntries);
|
|
18
|
+
extensionTrackData.push(trackData);
|
|
19
|
+
}
|
|
20
|
+
return extensionTrackData;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=Extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Extensions.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Extensions.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAG/D,OAAO,EAAC,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAElD,MAAM,UAAU,kCAAkC,CAC9C,gBAAsE,EACtE,kBAAyD;IAC3D,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2E,CAAC;IACvG,KAAK,MAAM,KAAK,IAAI,gBAAgB,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,CAClD,WAAW,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EACvE,GAAG,EAAE,CAAC,CAAC;YACL,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK;YACtB,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa;YAChD,iBAAiB,EAAE,EAAE;SACtB,CAAC,CAAC,CAAC;QACR,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IACD,KAAK,MAAM,SAAS,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;QAC7C,sBAAsB,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QACpD,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport type * as Types from '../types/types.js';\n\nimport {sortTraceEventsInPlace} from './Trace.js';\n\nexport function buildTrackDataFromExtensionEntries(\n extensionEntries: Types.Extensions.SyntheticExtensionFlameChartEntry[],\n extensionTrackData: Types.Extensions.ExtensionTrackData[]): Types.Extensions.ExtensionTrackData[] {\n const dataByTrack = new Map<string, Omit<Types.Extensions.ExtensionTrackData, 'tree'|'entryToNode'>>();\n for (const entry of extensionEntries) {\n const trackData = Platform.MapUtilities.getWithDefault(\n dataByTrack, `${entry.args.metadata.extensionName}.${entry.args.track}`,\n () => ({\n name: entry.args.track,\n extensionName: entry.args.metadata.extensionName,\n flameChartEntries: [],\n }));\n trackData.flameChartEntries.push(entry);\n }\n for (const trackData of dataByTrack.values()) {\n sortTraceEventsInPlace(trackData.flameChartEntries);\n extensionTrackData.push(trackData);\n }\n return extensionTrackData;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SamplesIntegrator.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SamplesIntegrator.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,aAAa,CAAC;AACvD,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;OAIG;IACH,wBAAwB,GAA6C,EAAE,CAAC;IACxE;;;;;;OAMG;IACH,eAAe,GAA6C,EAAE,CAAC;IAC/D;;OAEG;IACH,UAAU,CAA8B;IACxC;;OAEG;IACH,SAAS,CAA6B;IACtC;;;;;;;OAOG;IACH,mBAAmB,GAAa,EAAE,CAAC;IACnC;;;;;OAKG;IACH,iBAAiB,GAAG,KAAK,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAqD;IAClE;;;;;;;;OAQG;IACH,UAAU,GAAG,IAAI,GAAG,EAAmF,CAAC;IAExG,aAAa,CAAoC;IAEjD,YACI,YAAgE,EAAE,GAAgC,EAClG,GAA+B,EAAE,aAAiD;QACpF,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;IACpE,CAAC;IAED,iBAAiB,CAAC,WAA+C;QAC/D,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,EAAE,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC;QACrF,MAAM,KA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,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACrC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACjC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACzE,IAAI,kBAAkB;gBAClB,CAAC,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,CAAC,WAAW,CAAC,0BAA0B,CAAC,EAAE;gBAC9G,SAAS;aACV;YACD,MAAM,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACtG,IAAI,uBAAuB,IAAI,uBAAuB,KAAK,eAAe,EAAE;gBAC1E,SAAS;aACV;YACD,uBAAuB,GAAG,eAAe,CAAC;YAC1C,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SACvB;QACD,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACnB,CAAC;CACF","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Types from '../types/types.js';\n\nimport {millisecondsToMicroseconds} from './Timing.js';\nimport {makeProfileCall, mergeEventsInOrder} from './Trace.js';\n\n/**\n * This is a helper that integrates CPU profiling data coming in the\n * shape of samples, with trace events. Samples indicate what the JS\n * stack trace looked at a given point in time, but they don't have\n * duration. The SamplesIntegrator task is to make an approximation\n * of what the duration of each JS call was, given the sample data and\n * given the trace events profiled during that time. At the end of its\n * execution, the SamplesIntegrator returns an array of ProfileCalls\n * (under SamplesIntegrator::buildProfileCalls()), which\n * represent JS calls, with a call frame and duration. These calls have\n * the shape of a complete trace events and can be treated as flame\n * chart entries in the timeline.\n *\n * The approach to build the profile calls consists in tracking the\n * current stack as the following events happen (in order):\n * 1. A sample was done.\n * 2. A trace event started.\n * 3. A trace event ended.\n * Depending on the event and on the data that's coming with it the\n * stack is updated by adding or removing JS calls to it and updating\n * the duration of the calls in the tracking stack.\n *\n * note: Although this approach has been implemented since long ago, and\n * is relatively efficent (adds a complexity over the trace parsing of\n * O(n) where n is the number of samples) it has proven to be faulty.\n * It might be worthwhile experimenting with improvements or with a\n * completely different approach. Improving the approach is tracked in\n * crbug.com/1417439\n */\nexport class SamplesIntegrator {\n /**\n * The result of runing the samples integrator. Holds the JS calls\n * with their approximated duration after integrating samples into the\n * trace event tree.\n */\n #constructedProfileCalls: Types.TraceEvents.SyntheticProfileCall[] = [];\n /**\n * tracks the state of the JS stack at each point in time to update\n * the profile call durations as new events arrive. This doesn't only\n * happen with new profile calls (in which case we would compare the\n * stack in them) but also with trace events (in which case we would\n * update the duration of the events we are tracking at the moment).\n */\n #currentJSStack: Types.TraceEvents.SyntheticProfileCall[] = [];\n /**\n * Process holding the CPU profile and trace events.\n */\n #processId: Types.TraceEvents.ProcessID;\n /**\n * Thread holding the CPU profile and trace events.\n */\n #threadId: Types.TraceEvents.ThreadID;\n /**\n * Tracks the depth of the JS stack at the moment a trace event starts\n * or ends. It is assumed that for the duration of a trace event, the\n * JS stack's depth cannot decrease, since JS calls that started\n * before a trace event cannot end during the trace event. So as trace\n * events arrive, we store the \"locked\" amount of JS frames that were\n * in the stack before the event came.\n */\n #lockedJsStackDepth: number[] = [];\n /**\n * Used to keep track when samples should be integrated even if they\n * are not children of invocation trace events. This is useful in\n * cases where we can be missing the start of JS invocation events if\n * we start tracing half-way through.\n */\n #fakeJSInvocation = false;\n /**\n * The parsed CPU profile, holding the tree hierarchy of JS frames and\n * the sample data.\n */\n #profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Because GC nodes don't have a stack, we artificially add a stack to\n * them which corresponds to that of the previous sample. This map\n * tracks which node is used for the stack of a GC call.\n * Note that GC samples are not shown in the flamechart, however they\n * are used during the construction of for profile calls, as we can\n * infer information about the duration of the executed code when a\n * GC node is sampled.\n */\n #nodeForGC = new Map<Types.TraceEvents.SyntheticProfileCall, CPUProfile.ProfileTreeModel.ProfileNode>();\n\n #engineConfig: Types.Configuration.Configuration;\n\n constructor(\n profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel, pid: Types.TraceEvents.ProcessID,\n tid: Types.TraceEvents.ThreadID, configuration?: Types.Configuration.Configuration) {\n this.#profileModel = profileModel;\n this.#threadId = tid;\n this.#processId = pid;\n this.#engineConfig = configuration || Types.Configuration.DEFAULT;\n }\n\n buildProfileCalls(traceEvents: Types.TraceEvents.TraceEventData[]): Types.TraceEvents.SyntheticProfileCall[] {\n const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());\n const stack = [];\n for (let i = 0; i < mergedEvents.length; i++) {\n const event = mergedEvents[i];\n // Because instant trace events have no duration, they don't provide\n // useful information for possible changes in the duration of calls\n // in the JS stack.\n if (event.ph === Types.TraceEvents.Phase.INSTANT) {\n continue;\n }\n if (stack.length === 0) {\n if (Types.TraceEvents.isProfileCall(event)) {\n this.#onProfileCall(event);\n continue;\n }\n stack.push(event);\n this.#onTraceEventStart(event);\n continue;\n }\n\n const parentEvent = stack.at(-1);\n if (parentEvent === undefined) {\n continue;\n }\n const begin = event.ts;\n const parentBegin = parentEvent.ts;\n const parentDuration = parentEvent.dur || 0;\n const parentEnd = parentBegin + parentDuration;\n\n const startsAfterParent = begin >= parentEnd;\n if (startsAfterParent) {\n this.#onTraceEventEnd(parentEvent);\n stack.pop();\n i--;\n continue;\n }\n if (Types.TraceEvents.isProfileCall(event)) {\n this.#onProfileCall(event, parentEvent);\n continue;\n }\n this.#onTraceEventStart(event);\n stack.push(event);\n }\n while (stack.length) {\n const last = stack.pop();\n if (last) {\n this.#onTraceEventEnd(last);\n }\n }\n return this.#constructedProfileCalls;\n }\n\n #onTraceEventStart(event: Types.TraceEvents.TraceEventData): void {\n // Top level events cannot be nested into JS frames so we reset\n // the stack when we find one.\n if (event.name === Types.TraceEvents.KnownEventName.RunMicrotasks ||\n event.name === Types.TraceEvents.KnownEventName.RunTask) {\n this.#lockedJsStackDepth = [];\n this.#truncateJSStack(0, event.ts);\n this.#fakeJSInvocation = false;\n }\n\n if (this.#fakeJSInvocation) {\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);\n this.#fakeJSInvocation = false;\n }\n this.#extractStackTrace(event);\n // Keep track of the call frames in the stack before the event\n // happened. For the duration of this event, these frames cannot\n // change (none can be terminated before this event finishes).\n //\n // Also, every frame that is opened after this event, is considered\n // to be a descendant of the event. So once the event finishes, the\n // frames that were opened after it, need to be closed (see\n // onEndEvent).\n //\n // TODO(crbug.com/1417439):\n // The assumption that every frame opened after an event is a\n // descendant of the event is incorrect. For example, a JS call that\n // parents a trace event might have been sampled after the event was\n // dispatched. In this case the JS call would be discarded if this\n // event isn't an invocation event, otherwise the call will be\n // considered a child of the event. In both cases, the result would\n // be incorrect.\n this.#lockedJsStackDepth.push(this.#currentJSStack.length);\n }\n\n #onProfileCall(event: Types.TraceEvents.SyntheticProfileCall, parent?: Types.TraceEvents.TraceEventData): void {\n if ((parent && Types.TraceEvents.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {\n this.#extractStackTrace(event);\n } else if (Types.TraceEvents.isProfileCall(event) && this.#currentJSStack.length === 0) {\n // Force JS Samples to show up even if we are not inside a JS\n // invocation event, because we can be missing the start of JS\n // invocation events if we start tracing half-way through. Pretend\n // we have a top-level JS invocation event.\n this.#fakeJSInvocation = true;\n const stackDepthBefore = this.#currentJSStack.length;\n this.#extractStackTrace(event);\n this.#lockedJsStackDepth.push(stackDepthBefore);\n }\n }\n\n #onTraceEventEnd(event: Types.TraceEvents.TraceEventData): void {\n // Because the event has ended, any frames that happened after\n // this event are terminated. Frames that are ancestors to this\n // event are extended to cover its ending.\n const endTime = Types.Timing.MicroSeconds(event.ts + (event.dur || 0));\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);\n }\n\n /**\n * Builds the initial calls with no duration from samples. Their\n * purpose is to be merged with the trace event array being parsed so\n * that they can be traversed in order with them and their duration\n * can be updated as the SampleIntegrator callbacks are invoked.\n */\n callsFromProfileSamples(): Types.TraceEvents.SyntheticProfileCall[] {\n const samples = this.#profileModel.samples;\n const timestamps = this.#profileModel.timestamps;\n if (!samples) {\n return [];\n }\n const calls: Types.TraceEvents.SyntheticProfileCall[] = [];\n let prevNode;\n for (let i = 0; i < samples.length; i++) {\n const node = this.#profileModel.nodeByIndex(i);\n const timestamp = millisecondsToMicroseconds(Types.Timing.MilliSeconds(timestamps[i]));\n if (!node) {\n continue;\n }\n const call = makeProfileCall(node, timestamp, this.#processId, this.#threadId);\n calls.push(call);\n if (node.id === this.#profileModel.gcNode?.id && prevNode) {\n // GC samples have no stack, so we just put GC node on top of the\n // last recorded sample. Cache the previous sample for future\n // reference.\n this.#nodeForGC.set(call, prevNode);\n continue;\n }\n prevNode = node;\n }\n return calls;\n }\n\n #getStackTraceFromProfileCall(profileCall: Types.TraceEvents.SyntheticProfileCall):\n Types.TraceEvents.SyntheticProfileCall[] {\n let node = this.#profileModel.nodeById(profileCall.nodeId);\n const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;\n if (isGarbageCollection) {\n // Because GC don't have a stack, we use the stack of the previous\n // sample.\n node = this.#nodeForGC.get(profileCall) || null;\n }\n if (!node) {\n return [];\n }\n // `node.depth` is 0 based, so to set the size of the array we need\n // to add 1 to its value.\n const callFrames = new Array<Types.TraceEvents.SyntheticProfileCall>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = callFrames.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection call frame on top of the stack.\n callFrames[i--] = profileCall;\n }\n while (node) {\n callFrames[i--] = makeProfileCall(node, profileCall.ts, this.#processId, this.#threadId);\n node = node.parent;\n }\n return callFrames;\n }\n\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.TraceEvents.TraceEventData): void {\n const stackTrace =\n Types.TraceEvents.isProfileCall(event) ? this.#getStackTraceFromProfileCall(event) : this.#currentJSStack;\n SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);\n\n const endTime = event.ts + (event.dur || 0);\n const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);\n let i;\n // Merge a sample's stack frames with the stack frames we have\n // so far if we detect they are equivalent.\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // ^ t = x1 ^ t = x2\n\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // ^ t = x2\n for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {\n const newFrame = stackTrace[i].callFrame;\n const oldFrame = this.#currentJSStack[i].callFrame;\n if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {\n break;\n }\n // Scoot the right edge of this callFrame to the right\n this.#currentJSStack[i].dur =\n Types.Timing.MicroSeconds(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));\n }\n\n // If there are call frames in the sample that differ with the stack\n // we have, update the stack, but keeping the common frames in place\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // [-------D------] [E]\n // ^ t = x1 ^ t = x2\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // [E]\n // ^ t = x2\n this.#truncateJSStack(i, event.ts);\n\n for (; i < stackTrace.length; ++i) {\n const call = stackTrace[i];\n if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id ||\n call.nodeId === this.#profileModel.idleNode?.id || call.nodeId === this.#profileModel.gcNode?.id) {\n // Skip (root), (program) and (idle) frames, since this are not\n // relevant for web profiling and we don't want to show them in\n // the timeline.\n continue;\n }\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * When a call stack that differs from the one we are tracking has\n * been detected in the samples, the latter is \"truncated\" by\n * setting the ending time of its call frames and removing the top\n * call frames that aren't shared with the new call stack. This way,\n * we can update the tracked stack with the new call frames on top.\n * @param depth the amount of call frames from bottom to top that\n * should be kept in the tracking stack trace. AKA amount of shared\n * call frames between two stacks.\n * @param time the new end of the call frames in the stack.\n */\n #truncateJSStack(depth: number, time: Types.Timing.MicroSeconds): void {\n if (this.#lockedJsStackDepth.length) {\n const lockedDepth = this.#lockedJsStackDepth.at(-1);\n if (lockedDepth && depth < lockedDepth) {\n console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);\n depth = lockedDepth;\n }\n }\n if (this.#currentJSStack.length < depth) {\n console.error(`Trying to truncate higher than the current stack size at ${time}`);\n depth = this.#currentJSStack.length;\n }\n for (let k = 0; k < this.#currentJSStack.length; ++k) {\n this.#currentJSStack[k].dur = Types.Timing.MicroSeconds(Math.max(time - this.#currentJSStack[k].ts, 0));\n }\n this.#currentJSStack.length = depth;\n }\n\n static framesAreEqual(frame1: Protocol.Runtime.CallFrame, frame2: Protocol.Runtime.CallFrame): boolean {\n return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&\n frame1.lineNumber === frame2.lineNumber;\n }\n\n static showNativeName(name: string, runtimeCallStatsEnabled: boolean): boolean {\n return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));\n }\n\n static nativeGroup(nativeName: string): 'Parse'|'Compile'|null {\n if (nativeName.startsWith('Parse')) {\n return 'Parse';\n }\n if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {\n return 'Compile';\n }\n return null;\n }\n\n static isNativeRuntimeFrame(frame: Protocol.Runtime.CallFrame): boolean {\n return frame.url === 'native V8Runtime';\n }\n\n static filterStackFrames(\n stack: Types.TraceEvents.SyntheticProfileCall[], engineConfig: Types.Configuration.Configuration): void {\n const showAllEvents = engineConfig.experiments.timelineShowAllEvents;\n if (showAllEvents) {\n return;\n }\n let previousNativeFrameName: string|null = null;\n let j = 0;\n for (let i = 0; i < stack.length; ++i) {\n const frame = stack[i].callFrame;\n const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);\n if (nativeRuntimeFrame &&\n !SamplesIntegrator.showNativeName(frame.functionName, engineConfig.experiments.timelineV8RuntimeCallStats)) {\n continue;\n }\n const nativeFrameName = nativeRuntimeFrame ? SamplesIntegrator.nativeGroup(frame.functionName) : null;\n if (previousNativeFrameName && previousNativeFrameName === nativeFrameName) {\n continue;\n }\n previousNativeFrameName = nativeFrameName;\n stack[j++] = stack[i];\n }\n stack.length = j;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SamplesIntegrator.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SamplesIntegrator.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,aAAa,CAAC;AACvD,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;OAIG;IACH,wBAAwB,GAA6C,EAAE,CAAC;IACxE;;;;;;OAMG;IACH,eAAe,GAA6C,EAAE,CAAC;IAC/D;;OAEG;IACH,UAAU,CAA8B;IACxC;;OAEG;IACH,SAAS,CAA6B;IACtC;;;;;;;OAOG;IACH,mBAAmB,GAAa,EAAE,CAAC;IACnC;;;;;OAKG;IACH,iBAAiB,GAAG,KAAK,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAqD;IAClE;;;;;;;;OAQG;IACH,UA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D,MAAM,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACtG,IAAI,uBAAuB,IAAI,uBAAuB,KAAK,eAAe,EAAE,CAAC;gBAC3E,SAAS;YACX,CAAC;YACD,uBAAuB,GAAG,eAAe,CAAC;YAC1C,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACnB,CAAC;CACF","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Types from '../types/types.js';\n\nimport {millisecondsToMicroseconds} from './Timing.js';\nimport {makeProfileCall, mergeEventsInOrder} from './Trace.js';\n\n/**\n * This is a helper that integrates CPU profiling data coming in the\n * shape of samples, with trace events. Samples indicate what the JS\n * stack trace looked at a given point in time, but they don't have\n * duration. The SamplesIntegrator task is to make an approximation\n * of what the duration of each JS call was, given the sample data and\n * given the trace events profiled during that time. At the end of its\n * execution, the SamplesIntegrator returns an array of ProfileCalls\n * (under SamplesIntegrator::buildProfileCalls()), which\n * represent JS calls, with a call frame and duration. These calls have\n * the shape of a complete trace events and can be treated as flame\n * chart entries in the timeline.\n *\n * The approach to build the profile calls consists in tracking the\n * current stack as the following events happen (in order):\n * 1. A sample was done.\n * 2. A trace event started.\n * 3. A trace event ended.\n * Depending on the event and on the data that's coming with it the\n * stack is updated by adding or removing JS calls to it and updating\n * the duration of the calls in the tracking stack.\n *\n * note: Although this approach has been implemented since long ago, and\n * is relatively efficent (adds a complexity over the trace parsing of\n * O(n) where n is the number of samples) it has proven to be faulty.\n * It might be worthwhile experimenting with improvements or with a\n * completely different approach. Improving the approach is tracked in\n * crbug.com/1417439\n */\nexport class SamplesIntegrator {\n /**\n * The result of runing the samples integrator. Holds the JS calls\n * with their approximated duration after integrating samples into the\n * trace event tree.\n */\n #constructedProfileCalls: Types.TraceEvents.SyntheticProfileCall[] = [];\n /**\n * tracks the state of the JS stack at each point in time to update\n * the profile call durations as new events arrive. This doesn't only\n * happen with new profile calls (in which case we would compare the\n * stack in them) but also with trace events (in which case we would\n * update the duration of the events we are tracking at the moment).\n */\n #currentJSStack: Types.TraceEvents.SyntheticProfileCall[] = [];\n /**\n * Process holding the CPU profile and trace events.\n */\n #processId: Types.TraceEvents.ProcessID;\n /**\n * Thread holding the CPU profile and trace events.\n */\n #threadId: Types.TraceEvents.ThreadID;\n /**\n * Tracks the depth of the JS stack at the moment a trace event starts\n * or ends. It is assumed that for the duration of a trace event, the\n * JS stack's depth cannot decrease, since JS calls that started\n * before a trace event cannot end during the trace event. So as trace\n * events arrive, we store the \"locked\" amount of JS frames that were\n * in the stack before the event came.\n */\n #lockedJsStackDepth: number[] = [];\n /**\n * Used to keep track when samples should be integrated even if they\n * are not children of invocation trace events. This is useful in\n * cases where we can be missing the start of JS invocation events if\n * we start tracing half-way through.\n */\n #fakeJSInvocation = false;\n /**\n * The parsed CPU profile, holding the tree hierarchy of JS frames and\n * the sample data.\n */\n #profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Because GC nodes don't have a stack, we artificially add a stack to\n * them which corresponds to that of the previous sample. This map\n * tracks which node is used for the stack of a GC call.\n * Note that GC samples are not shown in the flamechart, however they\n * are used during the construction of for profile calls, as we can\n * infer information about the duration of the executed code when a\n * GC node is sampled.\n */\n #nodeForGC = new Map<Types.TraceEvents.SyntheticProfileCall, CPUProfile.ProfileTreeModel.ProfileNode>();\n\n #engineConfig: Types.Configuration.Configuration;\n\n constructor(\n profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel, pid: Types.TraceEvents.ProcessID,\n tid: Types.TraceEvents.ThreadID, configuration?: Types.Configuration.Configuration) {\n this.#profileModel = profileModel;\n this.#threadId = tid;\n this.#processId = pid;\n this.#engineConfig = configuration || Types.Configuration.DEFAULT;\n }\n\n buildProfileCalls(traceEvents: Types.TraceEvents.TraceEventData[]): Types.TraceEvents.SyntheticProfileCall[] {\n const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());\n const stack = [];\n for (let i = 0; i < mergedEvents.length; i++) {\n const event = mergedEvents[i];\n // Because instant trace events have no duration, they don't provide\n // useful information for possible changes in the duration of calls\n // in the JS stack.\n if (event.ph === Types.TraceEvents.Phase.INSTANT) {\n continue;\n }\n if (stack.length === 0) {\n if (Types.TraceEvents.isProfileCall(event)) {\n this.#onProfileCall(event);\n continue;\n }\n stack.push(event);\n this.#onTraceEventStart(event);\n continue;\n }\n\n const parentEvent = stack.at(-1);\n if (parentEvent === undefined) {\n continue;\n }\n const begin = event.ts;\n const parentBegin = parentEvent.ts;\n const parentDuration = parentEvent.dur || 0;\n const parentEnd = parentBegin + parentDuration;\n\n const startsAfterParent = begin >= parentEnd;\n if (startsAfterParent) {\n this.#onTraceEventEnd(parentEvent);\n stack.pop();\n i--;\n continue;\n }\n if (Types.TraceEvents.isProfileCall(event)) {\n this.#onProfileCall(event, parentEvent);\n continue;\n }\n this.#onTraceEventStart(event);\n stack.push(event);\n }\n while (stack.length) {\n const last = stack.pop();\n if (last) {\n this.#onTraceEventEnd(last);\n }\n }\n return this.#constructedProfileCalls;\n }\n\n #onTraceEventStart(event: Types.TraceEvents.TraceEventData): void {\n // Top level events cannot be nested into JS frames so we reset\n // the stack when we find one.\n if (event.name === Types.TraceEvents.KnownEventName.RunMicrotasks ||\n event.name === Types.TraceEvents.KnownEventName.RunTask) {\n this.#lockedJsStackDepth = [];\n this.#truncateJSStack(0, event.ts);\n this.#fakeJSInvocation = false;\n }\n\n if (this.#fakeJSInvocation) {\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);\n this.#fakeJSInvocation = false;\n }\n this.#extractStackTrace(event);\n // Keep track of the call frames in the stack before the event\n // happened. For the duration of this event, these frames cannot\n // change (none can be terminated before this event finishes).\n //\n // Also, every frame that is opened after this event, is considered\n // to be a descendant of the event. So once the event finishes, the\n // frames that were opened after it, need to be closed (see\n // onEndEvent).\n //\n // TODO(crbug.com/1417439):\n // The assumption that every frame opened after an event is a\n // descendant of the event is incorrect. For example, a JS call that\n // parents a trace event might have been sampled after the event was\n // dispatched. In this case the JS call would be discarded if this\n // event isn't an invocation event, otherwise the call will be\n // considered a child of the event. In both cases, the result would\n // be incorrect.\n this.#lockedJsStackDepth.push(this.#currentJSStack.length);\n }\n\n #onProfileCall(event: Types.TraceEvents.SyntheticProfileCall, parent?: Types.TraceEvents.TraceEventData): void {\n if ((parent && Types.TraceEvents.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {\n this.#extractStackTrace(event);\n } else if (Types.TraceEvents.isProfileCall(event) && this.#currentJSStack.length === 0) {\n // Force JS Samples to show up even if we are not inside a JS\n // invocation event, because we can be missing the start of JS\n // invocation events if we start tracing half-way through. Pretend\n // we have a top-level JS invocation event.\n this.#fakeJSInvocation = true;\n const stackDepthBefore = this.#currentJSStack.length;\n this.#extractStackTrace(event);\n this.#lockedJsStackDepth.push(stackDepthBefore);\n }\n }\n\n #onTraceEventEnd(event: Types.TraceEvents.TraceEventData): void {\n // Because the event has ended, any frames that happened after\n // this event are terminated. Frames that are ancestors to this\n // event are extended to cover its ending.\n const endTime = Types.Timing.MicroSeconds(event.ts + (event.dur || 0));\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);\n }\n\n /**\n * Builds the initial calls with no duration from samples. Their\n * purpose is to be merged with the trace event array being parsed so\n * that they can be traversed in order with them and their duration\n * can be updated as the SampleIntegrator callbacks are invoked.\n */\n callsFromProfileSamples(): Types.TraceEvents.SyntheticProfileCall[] {\n const samples = this.#profileModel.samples;\n const timestamps = this.#profileModel.timestamps;\n if (!samples) {\n return [];\n }\n const calls: Types.TraceEvents.SyntheticProfileCall[] = [];\n let prevNode;\n for (let i = 0; i < samples.length; i++) {\n const node = this.#profileModel.nodeByIndex(i);\n const timestamp = millisecondsToMicroseconds(Types.Timing.MilliSeconds(timestamps[i]));\n if (!node) {\n continue;\n }\n const call = makeProfileCall(node, timestamp, this.#processId, this.#threadId);\n calls.push(call);\n if (node.id === this.#profileModel.gcNode?.id && prevNode) {\n // GC samples have no stack, so we just put GC node on top of the\n // last recorded sample. Cache the previous sample for future\n // reference.\n this.#nodeForGC.set(call, prevNode);\n continue;\n }\n prevNode = node;\n }\n return calls;\n }\n\n #getStackTraceFromProfileCall(profileCall: Types.TraceEvents.SyntheticProfileCall):\n Types.TraceEvents.SyntheticProfileCall[] {\n let node = this.#profileModel.nodeById(profileCall.nodeId);\n const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;\n if (isGarbageCollection) {\n // Because GC don't have a stack, we use the stack of the previous\n // sample.\n node = this.#nodeForGC.get(profileCall) || null;\n }\n if (!node) {\n return [];\n }\n // `node.depth` is 0 based, so to set the size of the array we need\n // to add 1 to its value.\n const callFrames = new Array<Types.TraceEvents.SyntheticProfileCall>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = callFrames.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection call frame on top of the stack.\n callFrames[i--] = profileCall;\n }\n while (node) {\n callFrames[i--] = makeProfileCall(node, profileCall.ts, this.#processId, this.#threadId);\n node = node.parent;\n }\n return callFrames;\n }\n\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.TraceEvents.TraceEventData): void {\n const stackTrace =\n Types.TraceEvents.isProfileCall(event) ? this.#getStackTraceFromProfileCall(event) : this.#currentJSStack;\n SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);\n\n const endTime = event.ts + (event.dur || 0);\n const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);\n let i;\n // Merge a sample's stack frames with the stack frames we have\n // so far if we detect they are equivalent.\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // ^ t = x1 ^ t = x2\n\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // ^ t = x2\n for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {\n const newFrame = stackTrace[i].callFrame;\n const oldFrame = this.#currentJSStack[i].callFrame;\n if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {\n break;\n }\n // Scoot the right edge of this callFrame to the right\n this.#currentJSStack[i].dur =\n Types.Timing.MicroSeconds(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));\n }\n\n // If there are call frames in the sample that differ with the stack\n // we have, update the stack, but keeping the common frames in place\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // [-------D------] [E]\n // ^ t = x1 ^ t = x2\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // [E]\n // ^ t = x2\n this.#truncateJSStack(i, event.ts);\n\n for (; i < stackTrace.length; ++i) {\n const call = stackTrace[i];\n if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id ||\n call.nodeId === this.#profileModel.idleNode?.id || call.nodeId === this.#profileModel.gcNode?.id) {\n // Skip (root), (program) and (idle) frames, since this are not\n // relevant for web profiling and we don't want to show them in\n // the timeline.\n continue;\n }\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * When a call stack that differs from the one we are tracking has\n * been detected in the samples, the latter is \"truncated\" by\n * setting the ending time of its call frames and removing the top\n * call frames that aren't shared with the new call stack. This way,\n * we can update the tracked stack with the new call frames on top.\n * @param depth the amount of call frames from bottom to top that\n * should be kept in the tracking stack trace. AKA amount of shared\n * call frames between two stacks.\n * @param time the new end of the call frames in the stack.\n */\n #truncateJSStack(depth: number, time: Types.Timing.MicroSeconds): void {\n if (this.#lockedJsStackDepth.length) {\n const lockedDepth = this.#lockedJsStackDepth.at(-1);\n if (lockedDepth && depth < lockedDepth) {\n console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);\n depth = lockedDepth;\n }\n }\n if (this.#currentJSStack.length < depth) {\n console.error(`Trying to truncate higher than the current stack size at ${time}`);\n depth = this.#currentJSStack.length;\n }\n for (let k = 0; k < this.#currentJSStack.length; ++k) {\n this.#currentJSStack[k].dur = Types.Timing.MicroSeconds(Math.max(time - this.#currentJSStack[k].ts, 0));\n }\n this.#currentJSStack.length = depth;\n }\n\n static framesAreEqual(frame1: Protocol.Runtime.CallFrame, frame2: Protocol.Runtime.CallFrame): boolean {\n return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&\n frame1.lineNumber === frame2.lineNumber;\n }\n\n static showNativeName(name: string, runtimeCallStatsEnabled: boolean): boolean {\n return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));\n }\n\n static nativeGroup(nativeName: string): 'Parse'|'Compile'|null {\n if (nativeName.startsWith('Parse')) {\n return 'Parse';\n }\n if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {\n return 'Compile';\n }\n return null;\n }\n\n static isNativeRuntimeFrame(frame: Protocol.Runtime.CallFrame): boolean {\n return frame.url === 'native V8Runtime';\n }\n\n static filterStackFrames(\n stack: Types.TraceEvents.SyntheticProfileCall[], engineConfig: Types.Configuration.Configuration): void {\n const showAllEvents = engineConfig.experiments.timelineShowAllEvents;\n if (showAllEvents) {\n return;\n }\n let previousNativeFrameName: string|null = null;\n let j = 0;\n for (let i = 0; i < stack.length; ++i) {\n const frame = stack[i].callFrame;\n const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);\n if (nativeRuntimeFrame &&\n !SamplesIntegrator.showNativeName(frame.functionName, engineConfig.experiments.timelineV8RuntimeCallStats)) {\n continue;\n }\n const nativeFrameName = nativeRuntimeFrame ? SamplesIntegrator.nativeGroup(frame.functionName) : null;\n if (previousNativeFrameName && previousNativeFrameName === nativeFrameName) {\n continue;\n }\n previousNativeFrameName = nativeFrameName;\n stack[j++] = stack[i];\n }\n stack.length = j;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timing.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Timing.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,YAAY,CAAC;AAEtD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAgC,EAA6B,EAAE,CACtG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAA2B,EAA6B,EAAE,CAC5F,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAA2B,EAA6B,EAAE,CAC5F,0BAA0B,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;AAE7D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAgC,EAA6B,EAAE,CACtG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAgC,EAAwB,EAAE,CAC5F,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AAE9C,MAAM,UAAU,kBAAkB,CAAC,kBAA6C;IAC9E,IAA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AED,MAAM,UAAU,2BAA2B,CACvC,GAA8B,EAAE,GAA8B;IAChE,MAAM,WAAW,GAAyC;QACxD,GAAG,EAAE,0BAA0B,CAAC,GAAG,CAAC;QACpC,GAAG,EAAE,0BAA0B,CAAC,GAAG,CAAC;QACpC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,0BAA0B,CAAC,GAAG,CAAC,GAAG,0BAA0B,CAAC,GAAG,CAAC,CAAC;KACpG,CAAC;IACF,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,2BAA2B,CACvC,GAA8B,EAAE,GAA8B;IAChE,MAAM,WAAW,GAAyC;QACxD,GAAG;QACH,GAAG;QACH,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,GAAG,GAAG,CAAC;KAC5C,CAAC;IACF,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Types from '../types/types.js';\n\nimport {getNavigationForTraceEvent} from './Trace.js';\n\nexport const millisecondsToMicroseconds = (value: Types.Timing.MilliSeconds): Types.Timing.MicroSeconds =>\n Types.Timing.MicroSeconds(value * 1000);\n\nexport const secondsToMilliseconds = (value: Types.Timing.Seconds): Types.Timing.MilliSeconds =>\n Types.Timing.MilliSeconds(value * 1000);\n\nexport const secondsToMicroseconds = (value: Types.Timing.Seconds): Types.Timing.MicroSeconds =>\n millisecondsToMicroseconds(secondsToMilliseconds(value));\n\nexport const microSecondsToMilliseconds = (value: Types.Timing.MicroSeconds): Types.Timing.MilliSeconds =>\n Types.Timing.MilliSeconds(value / 1000);\n\nexport const microSecondsToSeconds = (value: Types.Timing.MicroSeconds): Types.Timing.Seconds =>\n Types.Timing.Seconds(value / 1000 / 1000);\n\nexport function detectBestTimeUnit(timeInMicroseconds: Types.Timing.MicroSeconds): Types.Timing.TimeUnit {\n if (timeInMicroseconds < 1000) {\n return Types.Timing.TimeUnit.MICROSECONDS;\n }\n\n const timeInMilliseconds = timeInMicroseconds / 1000;\n if (timeInMilliseconds < 1000) {\n return Types.Timing.TimeUnit.MILLISECONDS;\n }\n\n const timeInSeconds = timeInMilliseconds / 1000;\n if (timeInSeconds < 60) {\n return Types.Timing.TimeUnit.SECONDS;\n }\n\n return Types.Timing.TimeUnit.MINUTES;\n}\n\ninterface FormatOptions extends Intl.NumberFormatOptions {\n format?: Types.Timing.TimeUnit;\n}\n\nconst defaultFormatOptions = {\n style: 'unit',\n unit: 'millisecond',\n unitDisplay: 'narrow',\n};\n\n// Create a bunch of common formatters up front, so that we're not creating\n// them repeatedly during rendering.\nconst serialize = (value: {}): string => JSON.stringify(value);\nconst formatterFactory = (key: string|undefined): Intl.NumberFormat => {\n // If we pass undefined as the locale, that achieves two things:\n // 1. Avoids us referencing window.navigatior to fetch the locale, which is\n // useful given long term we would like this engine to run in NodeJS\n // environments.\n // 2. Will cause the formatter to fallback to the locale of the system, which\n // is likely going to be the most accurate one to use anyway.\n return new Intl.NumberFormat(undefined, key ? JSON.parse(key) : {});\n};\nconst formatters = new Map<string, Intl.NumberFormat>();\n\n// Microsecond Formatter.\nPlatform.MapUtilities.getWithDefault(formatters, serialize({style: 'decimal'}), formatterFactory);\n\n// Millisecond Formatter\nPlatform.MapUtilities.getWithDefault(formatters, serialize(defaultFormatOptions), formatterFactory);\n\n// Second Formatter\nPlatform.MapUtilities.getWithDefault(\n formatters, serialize({...defaultFormatOptions, unit: 'second'}), formatterFactory);\n\n// Minute Formatter\nPlatform.MapUtilities.getWithDefault(\n formatters, serialize({...defaultFormatOptions, unit: 'minute'}), formatterFactory);\n\nexport function formatMicrosecondsTime(\n timeInMicroseconds: Types.Timing.MicroSeconds, opts: FormatOptions = {}): string {\n if (!opts.format) {\n opts.format = detectBestTimeUnit(timeInMicroseconds);\n }\n\n const timeInMilliseconds = timeInMicroseconds / 1000;\n const timeInSeconds = timeInMilliseconds / 1000;\n const formatterOpts = {...defaultFormatOptions, ...opts};\n\n switch (opts.format) {\n case Types.Timing.TimeUnit.MICROSECONDS: {\n const formatter =\n Platform.MapUtilities.getWithDefault(formatters, serialize({style: 'decimal'}), formatterFactory);\n return `${formatter.format(timeInMicroseconds)}μs`;\n }\n\n case Types.Timing.TimeUnit.MILLISECONDS: {\n const formatter = Platform.MapUtilities.getWithDefault(formatters, serialize(formatterOpts), formatterFactory);\n return formatter.format(timeInMilliseconds);\n }\n\n case Types.Timing.TimeUnit.SECONDS: {\n const formatter = Platform.MapUtilities.getWithDefault(\n formatters, serialize({...formatterOpts, unit: 'second'}), formatterFactory);\n return formatter.format(timeInSeconds);\n }\n\n default: {\n // Switch to mins & seconds.\n const minuteFormatter = Platform.MapUtilities.getWithDefault(\n formatters, serialize({...formatterOpts, unit: 'minute'}), formatterFactory);\n const secondFormatter = Platform.MapUtilities.getWithDefault(\n formatters, serialize({...formatterOpts, unit: 'second'}), formatterFactory);\n const timeInMinutes = timeInSeconds / 60;\n const [mins, divider, fraction] = minuteFormatter.formatToParts(timeInMinutes);\n\n let seconds = 0;\n if (divider && fraction) {\n // Convert the fraction value (a string) to the nearest second.\n seconds = Math.round(Number(`0.${fraction.value}`) * 60);\n }\n return `${minuteFormatter.format(Number(mins.value))} ${secondFormatter.format(seconds)}`;\n }\n }\n}\n\nexport function timeStampForEventAdjustedByClosestNavigation(\n event: Types.TraceEvents.TraceEventData,\n traceBounds: Types.Timing.TraceWindowMicroSeconds,\n navigationsByNavigationId: Map<string, Types.TraceEvents.TraceEventNavigationStart>,\n navigationsByFrameId: Map<string, Types.TraceEvents.TraceEventNavigationStart[]>,\n ): Types.Timing.MicroSeconds {\n let eventTimeStamp = event.ts - traceBounds.min;\n if (event.args?.data?.navigationId) {\n const navigationForEvent = navigationsByNavigationId.get(event.args.data.navigationId);\n if (navigationForEvent) {\n eventTimeStamp = event.ts - navigationForEvent.ts;\n }\n } else if (event.args?.data?.frame) {\n const navigationForEvent = getNavigationForTraceEvent(event, event.args.data.frame, navigationsByFrameId);\n if (navigationForEvent) {\n eventTimeStamp = event.ts - navigationForEvent.ts;\n }\n }\n return Types.Timing.MicroSeconds(eventTimeStamp);\n}\n\nexport interface EventTimingsData<\n ValueType extends Types.Timing.MicroSeconds|Types.Timing.MilliSeconds|Types.Timing.Seconds,\n> {\n startTime: ValueType;\n endTime: ValueType;\n duration: ValueType;\n selfTime: ValueType;\n}\n\nexport function eventTimingsMicroSeconds(event: Types.TraceEvents.TraceEventData):\n EventTimingsData<Types.Timing.MicroSeconds> {\n return {\n startTime: event.ts,\n endTime: Types.Timing.MicroSeconds(event.ts + (event.dur || Types.Timing.MicroSeconds(0))),\n duration: Types.Timing.MicroSeconds(event.dur || 0),\n // TODO(crbug.com/1434599): Implement selfTime calculation for events\n // from the new engine.\n selfTime: Types.TraceEvents.isSyntheticTraceEntry(event) ? Types.Timing.MicroSeconds(event.selfTime || 0) :\n Types.Timing.MicroSeconds(event.dur || 0),\n };\n}\nexport function eventTimingsMilliSeconds(event: Types.TraceEvents.TraceEventData):\n EventTimingsData<Types.Timing.MilliSeconds> {\n const microTimes = eventTimingsMicroSeconds(event);\n return {\n startTime: microSecondsToMilliseconds(microTimes.startTime),\n endTime: microSecondsToMilliseconds(microTimes.endTime),\n duration: microSecondsToMilliseconds(microTimes.duration),\n selfTime: microSecondsToMilliseconds(microTimes.selfTime),\n };\n}\nexport function eventTimingsSeconds(event: Types.TraceEvents.TraceEventData): EventTimingsData<Types.Timing.Seconds> {\n const microTimes = eventTimingsMicroSeconds(event);\n return {\n startTime: microSecondsToSeconds(microTimes.startTime),\n endTime: microSecondsToSeconds(microTimes.endTime),\n duration: microSecondsToSeconds(microTimes.duration),\n selfTime: microSecondsToSeconds(microTimes.selfTime),\n };\n}\n\nexport function traceWindowMilliSeconds(bounds: Types.Timing.TraceWindowMicroSeconds):\n Types.Timing.TraceWindowMilliSeconds {\n return {\n min: microSecondsToMilliseconds(bounds.min),\n max: microSecondsToMilliseconds(bounds.max),\n range: microSecondsToMilliseconds(bounds.range),\n };\n}\n\nexport function traceWindowMillisecondsToMicroSeconds(bounds: Types.Timing.TraceWindowMilliSeconds):\n Types.Timing.TraceWindowMicroSeconds {\n return {\n min: millisecondsToMicroseconds(bounds.min),\n max: millisecondsToMicroseconds(bounds.max),\n range: millisecondsToMicroseconds(bounds.range),\n };\n}\n\nexport function traceWindowFromMilliSeconds(\n min: Types.Timing.MilliSeconds, max: Types.Timing.MilliSeconds): Types.Timing.TraceWindowMicroSeconds {\n const traceWindow: Types.Timing.TraceWindowMicroSeconds = {\n min: millisecondsToMicroseconds(min),\n max: millisecondsToMicroseconds(max),\n range: Types.Timing.MicroSeconds(millisecondsToMicroseconds(max) - millisecondsToMicroseconds(min)),\n };\n return traceWindow;\n}\n\nexport function traceWindowFromMicroSeconds(\n min: Types.Timing.MicroSeconds, max: Types.Timing.MicroSeconds): Types.Timing.TraceWindowMicroSeconds {\n const traceWindow: Types.Timing.TraceWindowMicroSeconds = {\n min,\n max,\n range: Types.Timing.MicroSeconds(max - min),\n };\n return traceWindow;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Timing.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Timing.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,YAAY,CAAC;AAEtD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAgC,EAA6B,EAAE,CACtG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAA2B,EAA6B,EAAE,CAC5F,KAAK,CAAC,MAAM,CAAC,YAAY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ourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Types from '../types/types.js';\n\nimport {getNavigationForTraceEvent} from './Trace.js';\n\nexport const millisecondsToMicroseconds = (value: Types.Timing.MilliSeconds): Types.Timing.MicroSeconds =>\n Types.Timing.MicroSeconds(value * 1000);\n\nexport const secondsToMilliseconds = (value: Types.Timing.Seconds): Types.Timing.MilliSeconds =>\n Types.Timing.MilliSeconds(value * 1000);\n\nexport const secondsToMicroseconds = (value: Types.Timing.Seconds): Types.Timing.MicroSeconds =>\n millisecondsToMicroseconds(secondsToMilliseconds(value));\n\nexport const microSecondsToMilliseconds = (value: Types.Timing.MicroSeconds): Types.Timing.MilliSeconds =>\n Types.Timing.MilliSeconds(value / 1000);\n\nexport const microSecondsToSeconds = (value: Types.Timing.MicroSeconds): Types.Timing.Seconds =>\n Types.Timing.Seconds(value / 1000 / 1000);\n\nexport function detectBestTimeUnit(timeInMicroseconds: Types.Timing.MicroSeconds): Types.Timing.TimeUnit {\n if (timeInMicroseconds < 1000) {\n return Types.Timing.TimeUnit.MICROSECONDS;\n }\n\n const timeInMilliseconds = timeInMicroseconds / 1000;\n if (timeInMilliseconds < 1000) {\n return Types.Timing.TimeUnit.MILLISECONDS;\n }\n\n const timeInSeconds = timeInMilliseconds / 1000;\n if (timeInSeconds < 60) {\n return Types.Timing.TimeUnit.SECONDS;\n }\n\n return Types.Timing.TimeUnit.MINUTES;\n}\n\ninterface FormatOptions extends Intl.NumberFormatOptions {\n format?: Types.Timing.TimeUnit;\n}\n\nconst defaultFormatOptions = {\n style: 'unit',\n unit: 'millisecond',\n unitDisplay: 'narrow',\n};\n\n// Create a bunch of common formatters up front, so that we're not creating\n// them repeatedly during rendering.\nconst serialize = (value: {}): string => JSON.stringify(value);\nconst formatterFactory = (key: string|undefined): Intl.NumberFormat => {\n // If we pass undefined as the locale, that achieves two things:\n // 1. Avoids us referencing window.navigatior to fetch the locale, which is\n // useful given long term we would like this engine to run in NodeJS\n // environments.\n // 2. Will cause the formatter to fallback to the locale of the system, which\n // is likely going to be the most accurate one to use anyway.\n return new Intl.NumberFormat(undefined, key ? JSON.parse(key) : {});\n};\nconst formatters = new Map<string, Intl.NumberFormat>();\n\n// Microsecond Formatter.\nPlatform.MapUtilities.getWithDefault(formatters, serialize({style: 'decimal'}), formatterFactory);\n\n// Millisecond Formatter\nPlatform.MapUtilities.getWithDefault(formatters, serialize(defaultFormatOptions), formatterFactory);\n\n// Second Formatter\nPlatform.MapUtilities.getWithDefault(\n formatters, serialize({...defaultFormatOptions, unit: 'second'}), formatterFactory);\n\n// Minute Formatter\nPlatform.MapUtilities.getWithDefault(\n formatters, serialize({...defaultFormatOptions, unit: 'minute'}), formatterFactory);\n\nexport function formatMicrosecondsTime(\n timeInMicroseconds: Types.Timing.MicroSeconds, opts: FormatOptions = {}): string {\n if (!opts.format) {\n opts.format = detectBestTimeUnit(timeInMicroseconds);\n }\n\n const timeInMilliseconds = timeInMicroseconds / 1000;\n const timeInSeconds = timeInMilliseconds / 1000;\n const formatterOpts = {...defaultFormatOptions, ...opts};\n\n switch (opts.format) {\n case Types.Timing.TimeUnit.MICROSECONDS: {\n const formatter =\n Platform.MapUtilities.getWithDefault(formatters, serialize({style: 'decimal'}), formatterFactory);\n return `${formatter.format(timeInMicroseconds)}μs`;\n }\n\n case Types.Timing.TimeUnit.MILLISECONDS: {\n const formatter = Platform.MapUtilities.getWithDefault(formatters, serialize(formatterOpts), formatterFactory);\n return formatter.format(timeInMilliseconds);\n }\n\n case Types.Timing.TimeUnit.SECONDS: {\n const formatter = Platform.MapUtilities.getWithDefault(\n formatters, serialize({...formatterOpts, unit: 'second'}), formatterFactory);\n return formatter.format(timeInSeconds);\n }\n\n default: {\n // Switch to mins & seconds.\n const minuteFormatter = Platform.MapUtilities.getWithDefault(\n formatters, serialize({...formatterOpts, unit: 'minute'}), formatterFactory);\n const secondFormatter = Platform.MapUtilities.getWithDefault(\n formatters, serialize({...formatterOpts, unit: 'second'}), formatterFactory);\n const timeInMinutes = timeInSeconds / 60;\n const [mins, divider, fraction] = minuteFormatter.formatToParts(timeInMinutes);\n\n let seconds = 0;\n if (divider && fraction) {\n // Convert the fraction value (a string) to the nearest second.\n seconds = Math.round(Number(`0.${fraction.value}`) * 60);\n }\n return `${minuteFormatter.format(Number(mins.value))} ${secondFormatter.format(seconds)}`;\n }\n }\n}\n\nexport function timeStampForEventAdjustedByClosestNavigation(\n event: Types.TraceEvents.TraceEventData,\n traceBounds: Types.Timing.TraceWindowMicroSeconds,\n navigationsByNavigationId: Map<string, Types.TraceEvents.TraceEventNavigationStart>,\n navigationsByFrameId: Map<string, Types.TraceEvents.TraceEventNavigationStart[]>,\n ): Types.Timing.MicroSeconds {\n let eventTimeStamp = event.ts - traceBounds.min;\n if (event.args?.data?.navigationId) {\n const navigationForEvent = navigationsByNavigationId.get(event.args.data.navigationId);\n if (navigationForEvent) {\n eventTimeStamp = event.ts - navigationForEvent.ts;\n }\n } else if (event.args?.data?.frame) {\n const navigationForEvent = getNavigationForTraceEvent(event, event.args.data.frame, navigationsByFrameId);\n if (navigationForEvent) {\n eventTimeStamp = event.ts - navigationForEvent.ts;\n }\n }\n return Types.Timing.MicroSeconds(eventTimeStamp);\n}\n\nexport interface EventTimingsData<\n ValueType extends Types.Timing.MicroSeconds|Types.Timing.MilliSeconds|Types.Timing.Seconds,\n> {\n startTime: ValueType;\n endTime: ValueType;\n duration: ValueType;\n selfTime: ValueType;\n}\n\nexport function eventTimingsMicroSeconds(event: Types.TraceEvents.TraceEventData):\n EventTimingsData<Types.Timing.MicroSeconds> {\n return {\n startTime: event.ts,\n endTime: Types.Timing.MicroSeconds(event.ts + (event.dur || Types.Timing.MicroSeconds(0))),\n duration: Types.Timing.MicroSeconds(event.dur || 0),\n // TODO(crbug.com/1434599): Implement selfTime calculation for events\n // from the new engine.\n selfTime: Types.TraceEvents.isSyntheticTraceEntry(event) ? Types.Timing.MicroSeconds(event.selfTime || 0) :\n Types.Timing.MicroSeconds(event.dur || 0),\n };\n}\nexport function eventTimingsMilliSeconds(event: Types.TraceEvents.TraceEventData):\n EventTimingsData<Types.Timing.MilliSeconds> {\n const microTimes = eventTimingsMicroSeconds(event);\n return {\n startTime: microSecondsToMilliseconds(microTimes.startTime),\n endTime: microSecondsToMilliseconds(microTimes.endTime),\n duration: microSecondsToMilliseconds(microTimes.duration),\n selfTime: microSecondsToMilliseconds(microTimes.selfTime),\n };\n}\nexport function eventTimingsSeconds(event: Types.TraceEvents.TraceEventData): EventTimingsData<Types.Timing.Seconds> {\n const microTimes = eventTimingsMicroSeconds(event);\n return {\n startTime: microSecondsToSeconds(microTimes.startTime),\n endTime: microSecondsToSeconds(microTimes.endTime),\n duration: microSecondsToSeconds(microTimes.duration),\n selfTime: microSecondsToSeconds(microTimes.selfTime),\n };\n}\n\nexport function traceWindowMilliSeconds(bounds: Types.Timing.TraceWindowMicroSeconds):\n Types.Timing.TraceWindowMilliSeconds {\n return {\n min: microSecondsToMilliseconds(bounds.min),\n max: microSecondsToMilliseconds(bounds.max),\n range: microSecondsToMilliseconds(bounds.range),\n };\n}\n\nexport function traceWindowMillisecondsToMicroSeconds(bounds: Types.Timing.TraceWindowMilliSeconds):\n Types.Timing.TraceWindowMicroSeconds {\n return {\n min: millisecondsToMicroseconds(bounds.min),\n max: millisecondsToMicroseconds(bounds.max),\n range: millisecondsToMicroseconds(bounds.range),\n };\n}\n\nexport function traceWindowFromMilliSeconds(\n min: Types.Timing.MilliSeconds, max: Types.Timing.MilliSeconds): Types.Timing.TraceWindowMicroSeconds {\n const traceWindow: Types.Timing.TraceWindowMicroSeconds = {\n min: millisecondsToMicroseconds(min),\n max: millisecondsToMicroseconds(max),\n range: Types.Timing.MicroSeconds(millisecondsToMicroseconds(max) - millisecondsToMicroseconds(min)),\n };\n return traceWindow;\n}\n\nexport function traceWindowFromMicroSeconds(\n min: Types.Timing.MicroSeconds, max: Types.Timing.MicroSeconds): Types.Timing.TraceWindowMicroSeconds {\n const traceWindow: Types.Timing.TraceWindowMicroSeconds = {\n min,\n max,\n range: Types.Timing.MicroSeconds(max - min),\n };\n return traceWindow;\n}\n"]}
|
|
@@ -17,7 +17,7 @@ export declare function sortTraceEventsInPlace(events: {
|
|
|
17
17
|
* Returns an array of ordered events that results after merging the two
|
|
18
18
|
* ordered input arrays.
|
|
19
19
|
*/
|
|
20
|
-
export declare function mergeEventsInOrder<T1 extends Types.TraceEvents.TraceEventData, T2 extends Types.TraceEvents.TraceEventData>(eventsArray1: T1[], eventsArray2: T2[]): (T1 | T2)[];
|
|
20
|
+
export declare function mergeEventsInOrder<T1 extends Types.TraceEvents.TraceEventData, T2 extends Types.TraceEvents.TraceEventData>(eventsArray1: readonly T1[], eventsArray2: readonly T2[]): (T1 | T2)[];
|
|
21
21
|
export declare function getNavigationForTraceEvent(event: Types.TraceEvents.TraceEventData, eventFrameId: string, navigationsByFrameId: Map<string, Types.TraceEvents.TraceEventNavigationStart[]>): Types.TraceEvents.TraceEventNavigationStart | null;
|
|
22
22
|
export declare function extractId(event: Types.TraceEvents.TraceEventPairableAsync | MatchedPairType<Types.TraceEvents.TraceEventPairableAsync>): string | undefined;
|
|
23
23
|
export declare function activeURLForFrameAtTime(frameId: string, time: Types.Timing.MicroSeconds, rendererProcessesByFrame: Map<string, Map<Types.TraceEvents.ProcessID, {
|
|
@@ -25,6 +25,7 @@ export declare function activeURLForFrameAtTime(frameId: string, time: Types.Tim
|
|
|
25
25
|
window: Types.Timing.TraceWindowMicroSeconds;
|
|
26
26
|
}[]>>): string | null;
|
|
27
27
|
export declare function makeProfileCall(node: CPUProfile.ProfileTreeModel.ProfileNode, ts: Types.Timing.MicroSeconds, pid: Types.TraceEvents.ProcessID, tid: Types.TraceEvents.ThreadID): Types.TraceEvents.SyntheticProfileCall;
|
|
28
|
+
export declare function makeSyntheticTraceEntry(name: string, ts: Types.Timing.MicroSeconds, pid: Types.TraceEvents.ProcessID, tid: Types.TraceEvents.ThreadID): Types.TraceEvents.SyntheticTraceEntry;
|
|
28
29
|
export declare function matchBeginningAndEndEvents(unpairedEvents: Types.TraceEvents.TraceEventPairableAsync[]): Map<string, {
|
|
29
30
|
begin: Types.TraceEvents.TraceEventPairableAsyncBegin | null;
|
|
30
31
|
end: Types.TraceEvents.TraceEventPairableAsyncEnd | null;
|
|
@@ -32,6 +33,6 @@ export declare function matchBeginningAndEndEvents(unpairedEvents: Types.TraceEv
|
|
|
32
33
|
export declare function createSortedSyntheticEvents<T extends Types.TraceEvents.TraceEventPairableAsync>(matchedPairs: Map<string, {
|
|
33
34
|
begin: Types.TraceEvents.TraceEventPairableAsyncBegin | null;
|
|
34
35
|
end: Types.TraceEvents.TraceEventPairableAsyncEnd | null;
|
|
35
|
-
}>): MatchedPairType<T>[];
|
|
36
|
-
export declare function createMatchedSortedSyntheticEvents<T extends Types.TraceEvents.TraceEventPairableAsync>(unpairedAsyncEvents: T[]): MatchedPairType<T>[];
|
|
36
|
+
}>, syntheticEventCallback?: (syntheticEvent: MatchedPairType<T>) => void): MatchedPairType<T>[];
|
|
37
|
+
export declare function createMatchedSortedSyntheticEvents<T extends Types.TraceEvents.TraceEventPairableAsync>(unpairedAsyncEvents: T[], syntheticEventCallback?: (syntheticEvent: MatchedPairType<T>) => void): MatchedPairType<T>[];
|
|
37
38
|
export {};
|