diff --git a/src/trace-processing/parse.ts b/src/trace-processing/parse.ts index 1b2e24c0f..34a56882f 100644 --- a/src/trace-processing/parse.ts +++ b/src/trace-processing/parse.ts @@ -73,11 +73,19 @@ export async function parseRawTraceBuffer( } } +const extraFormatDescriptions = `Information on performance traces may contain main thread activity represented as call frames and network requests. + +${PerformanceTraceFormatter.callFrameDataFormatDescription} + +${PerformanceTraceFormatter.networkDataFormatDescription} +`; export function getTraceSummary(result: TraceResult): string { const focus = AgentFocus.fromParsedTrace(result.parsedTrace); const formatter = new PerformanceTraceFormatter(focus); const output = formatter.formatTraceSummary(); - return output; + return `${extraFormatDescriptions} + +${output}`; } export type InsightName = keyof TraceEngine.Insights.Types.InsightModels; diff --git a/tests/tools/performance.test.js.snapshot b/tests/tools/performance.test.js.snapshot index feaa87597..071909f47 100644 --- a/tests/tools/performance.test.js.snapshot +++ b/tests/tools/performance.test.js.snapshot @@ -51,6 +51,62 @@ No buffer was provided. exports[`performance > performance_stop_trace > returns the high level summary of the performance trace 1`] = ` The performance trace has been stopped. Here is a high level summary of the trace and the Insights that were found: +Information on performance traces may contain main thread activity represented as call frames and network requests. + +Each call frame is presented in the following format: + +'id;eventKey;name;duration;selfTime;urlIndex;childRange;[S]' + +Key definitions: + +* id: A unique numerical identifier for the call frame. Never mention this id in the output to the user. +* eventKey: String that uniquely identifies this event in the flame chart. +* name: A concise string describing the call frame (e.g., 'Evaluate Script', 'render', 'fetchData'). +* duration: The total execution time of the call frame, including its children. +* selfTime: The time spent directly within the call frame, excluding its children's execution. +* urlIndex: Index referencing the "All URLs" list. Empty if no specific script URL is associated. +* childRange: Specifies the direct children of this node using their IDs. If empty ('' or 'S' at the end), the node has no children. If a single number (e.g., '4'), the node has one child with that ID. If in the format 'firstId-lastId' (e.g., '4-5'), it indicates a consecutive range of child IDs from 'firstId' to 'lastId', inclusive. +* S: _Optional_. The letter 'S' terminates the line if that call frame was selected by the user. + +Example Call Tree: + +1;r-123;main;500;100;; +2;r-124;update;200;50;;3 +3;p-49575-15428179-2834-374;animate;150;20;0;4-5;S +4;p-49575-15428179-3505-1162;calculatePosition;80;80;; +5;p-49575-15428179-5391-2767;applyStyles;50;50;; + + +Network requests are formatted like this: +\`urlIndex;eventKey;queuedTime;requestSentTime;downloadCompleteTime;processingCompleteTime;totalDuration;downloadDuration;mainThreadProcessingDuration;statusCode;mimeType;priority;initialPriority;finalPriority;renderBlocking;protocol;fromServiceWorker;initiators;redirects:[[redirectUrlIndex|startTime|duration]];responseHeaders:[header1Value|header2Value|...]\` + +- \`urlIndex\`: Numerical index for the request's URL, referencing the "All URLs" list. +- \`eventKey\`: String that uniquely identifies this request's trace event. +Timings (all in milliseconds, relative to navigation start): +- \`queuedTime\`: When the request was queued. +- \`requestSentTime\`: When the request was sent. +- \`downloadCompleteTime\`: When the download completed. +- \`processingCompleteTime\`: When main thread processing finished. +Durations (all in milliseconds): +- \`totalDuration\`: Total time from the request being queued until its main thread processing completed. +- \`downloadDuration\`: Time spent actively downloading the resource. +- \`mainThreadProcessingDuration\`: Time spent on the main thread after the download completed. +- \`statusCode\`: The HTTP status code of the response (e.g., 200, 404). +- \`mimeType\`: The MIME type of the resource (e.g., "text/html", "application/javascript"). +- \`priority\`: The final network request priority (e.g., "VeryHigh", "Low"). +- \`initialPriority\`: The initial network request priority. +- \`finalPriority\`: The final network request priority (redundant if \`priority\` is always final, but kept for clarity if \`initialPriority\` and \`priority\` differ). +- \`renderBlocking\`: 't' if the request was render-blocking, 'f' otherwise. +- \`protocol\`: The network protocol used (e.g., "h2", "http/1.1"). +- \`fromServiceWorker\`: 't' if the request was served from a service worker, 'f' otherwise. +- \`initiators\`: A list (separated by ,) of URL indices for the initiator chain of this request. Listed in order starting from the root request to the request that directly loaded this one. This represents the network dependencies necessary to load this request. If there is no initiator, this is empty. +- \`redirects\`: A comma-separated list of redirects, enclosed in square brackets. Each redirect is formatted as +\`[redirectUrlIndex|startTime|duration]\`, where: \`redirectUrlIndex\`: Numerical index for the redirect's URL. \`startTime\`: The start time of the redirect in milliseconds, relative to navigation start. \`duration\`: The duration of the redirect in milliseconds. +- \`responseHeaders\`: A list (separated by '|') of values for specific, pre-defined response headers, enclosed in square brackets. +The order of headers corresponds to an internal fixed list. If a header is not present, its value will be empty. + + + URL: https://web.dev/ Bounds: {min: 122410994891, max: 122416385853} CPU throttling: none diff --git a/tests/trace-processing/parse.test.js.snapshot b/tests/trace-processing/parse.test.js.snapshot index f4a4fbf08..5ce7918fe 100644 --- a/tests/trace-processing/parse.test.js.snapshot +++ b/tests/trace-processing/parse.test.js.snapshot @@ -1,4 +1,60 @@ exports[`Trace parsing > can format results of a trace 1`] = ` +Information on performance traces may contain main thread activity represented as call frames and network requests. + +Each call frame is presented in the following format: + +'id;eventKey;name;duration;selfTime;urlIndex;childRange;[S]' + +Key definitions: + +* id: A unique numerical identifier for the call frame. Never mention this id in the output to the user. +* eventKey: String that uniquely identifies this event in the flame chart. +* name: A concise string describing the call frame (e.g., 'Evaluate Script', 'render', 'fetchData'). +* duration: The total execution time of the call frame, including its children. +* selfTime: The time spent directly within the call frame, excluding its children's execution. +* urlIndex: Index referencing the "All URLs" list. Empty if no specific script URL is associated. +* childRange: Specifies the direct children of this node using their IDs. If empty ('' or 'S' at the end), the node has no children. If a single number (e.g., '4'), the node has one child with that ID. If in the format 'firstId-lastId' (e.g., '4-5'), it indicates a consecutive range of child IDs from 'firstId' to 'lastId', inclusive. +* S: _Optional_. The letter 'S' terminates the line if that call frame was selected by the user. + +Example Call Tree: + +1;r-123;main;500;100;; +2;r-124;update;200;50;;3 +3;p-49575-15428179-2834-374;animate;150;20;0;4-5;S +4;p-49575-15428179-3505-1162;calculatePosition;80;80;; +5;p-49575-15428179-5391-2767;applyStyles;50;50;; + + +Network requests are formatted like this: +\`urlIndex;eventKey;queuedTime;requestSentTime;downloadCompleteTime;processingCompleteTime;totalDuration;downloadDuration;mainThreadProcessingDuration;statusCode;mimeType;priority;initialPriority;finalPriority;renderBlocking;protocol;fromServiceWorker;initiators;redirects:[[redirectUrlIndex|startTime|duration]];responseHeaders:[header1Value|header2Value|...]\` + +- \`urlIndex\`: Numerical index for the request's URL, referencing the "All URLs" list. +- \`eventKey\`: String that uniquely identifies this request's trace event. +Timings (all in milliseconds, relative to navigation start): +- \`queuedTime\`: When the request was queued. +- \`requestSentTime\`: When the request was sent. +- \`downloadCompleteTime\`: When the download completed. +- \`processingCompleteTime\`: When main thread processing finished. +Durations (all in milliseconds): +- \`totalDuration\`: Total time from the request being queued until its main thread processing completed. +- \`downloadDuration\`: Time spent actively downloading the resource. +- \`mainThreadProcessingDuration\`: Time spent on the main thread after the download completed. +- \`statusCode\`: The HTTP status code of the response (e.g., 200, 404). +- \`mimeType\`: The MIME type of the resource (e.g., "text/html", "application/javascript"). +- \`priority\`: The final network request priority (e.g., "VeryHigh", "Low"). +- \`initialPriority\`: The initial network request priority. +- \`finalPriority\`: The final network request priority (redundant if \`priority\` is always final, but kept for clarity if \`initialPriority\` and \`priority\` differ). +- \`renderBlocking\`: 't' if the request was render-blocking, 'f' otherwise. +- \`protocol\`: The network protocol used (e.g., "h2", "http/1.1"). +- \`fromServiceWorker\`: 't' if the request was served from a service worker, 'f' otherwise. +- \`initiators\`: A list (separated by ,) of URL indices for the initiator chain of this request. Listed in order starting from the root request to the request that directly loaded this one. This represents the network dependencies necessary to load this request. If there is no initiator, this is empty. +- \`redirects\`: A comma-separated list of redirects, enclosed in square brackets. Each redirect is formatted as +\`[redirectUrlIndex|startTime|duration]\`, where: \`redirectUrlIndex\`: Numerical index for the redirect's URL. \`startTime\`: The start time of the redirect in milliseconds, relative to navigation start. \`duration\`: The duration of the redirect in milliseconds. +- \`responseHeaders\`: A list (separated by '|') of values for specific, pre-defined response headers, enclosed in square brackets. +The order of headers corresponds to an internal fixed list. If a header is not present, its value will be empty. + + + URL: https://web.dev/ Bounds: {min: 122410994891, max: 122416385853} CPU throttling: none