@paulirish/trace_engine 0.0.25 → 0.0.26
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/core/platform/TypedArrayUtilities.d.ts +7 -0
- package/core/platform/TypedArrayUtilities.js +41 -0
- package/core/platform/TypedArrayUtilities.js.map +1 -1
- package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -1
- package/core/platform/platform-tsconfig.json +0 -1
- package/generated/protocol.d.ts +36 -2
- package/models/cpu_profile/cpu_profile-tsconfig.json +0 -1
- package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -1
- package/models/trace/LanternComputationData.d.ts +8 -0
- package/models/trace/LanternComputationData.js +368 -0
- package/models/trace/LanternComputationData.js.map +1 -0
- package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -1
- package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -1
- package/models/trace/extras/extras-tsconfig.json +0 -1
- package/models/trace/handlers/EnhancedTracesHandler.d.ts +46 -0
- package/models/trace/handlers/EnhancedTracesHandler.js +137 -0
- package/models/trace/handlers/EnhancedTracesHandler.js.map +1 -0
- package/models/trace/handlers/LayoutShiftsHandler.d.ts +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.js +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.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/UserInteractionsHandler.d.ts +6 -0
- package/models/trace/handlers/UserInteractionsHandler.js +15 -0
- package/models/trace/handlers/UserInteractionsHandler.js.map +1 -1
- package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -1
- package/models/trace/handlers/handlers-tsconfig.json +1 -1
- package/models/trace/helpers/Timing.d.ts +0 -6
- package/models/trace/helpers/Timing.js +0 -76
- package/models/trace/helpers/Timing.js.map +1 -1
- package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -1
- package/models/trace/helpers/helpers-tsconfig.json +0 -1
- package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -1
- package/models/trace/insights/insights-tsconfig.json +0 -1
- package/models/trace/lantern/BaseNode.d.ts +91 -0
- package/models/trace/lantern/BaseNode.js +268 -0
- package/models/trace/lantern/BaseNode.js.map +1 -0
- package/models/trace/lantern/CPUNode.d.ts +24 -0
- package/models/trace/lantern/CPUNode.js +64 -0
- package/models/trace/lantern/CPUNode.js.map +1 -0
- package/models/trace/lantern/LanternError.d.ts +3 -0
- package/models/trace/lantern/LanternError.js +7 -0
- package/models/trace/lantern/LanternError.js.map +1 -0
- package/models/trace/lantern/MetricsModule.d.ts +11 -0
- package/models/trace/lantern/MetricsModule.js +14 -0
- package/models/trace/lantern/MetricsModule.js.map +1 -0
- package/models/trace/lantern/NetworkNode.d.ts +22 -0
- package/models/trace/lantern/NetworkNode.js +83 -0
- package/models/trace/lantern/NetworkNode.js.map +1 -0
- package/models/trace/lantern/PageDependencyGraph.d.ts +43 -0
- package/models/trace/lantern/PageDependencyGraph.js +509 -0
- package/models/trace/lantern/PageDependencyGraph.js.map +1 -0
- package/models/trace/lantern/SimulationModule.d.ts +17 -0
- package/models/trace/lantern/SimulationModule.js +13 -0
- package/models/trace/lantern/SimulationModule.js.map +1 -0
- package/models/trace/lantern/bundle-tsconfig.json +1 -0
- package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +42 -0
- package/models/trace/lantern/lantern-tsconfig.json +64 -0
- package/models/trace/lantern/lantern.d.ts +29 -0
- package/models/trace/lantern/lantern.js +33 -0
- package/models/trace/lantern/lantern.js.map +1 -0
- package/models/trace/lantern/metrics/FirstContentfulPaint.d.ts +42 -0
- package/models/trace/lantern/metrics/FirstContentfulPaint.js +137 -0
- package/models/trace/lantern/metrics/FirstContentfulPaint.js.map +1 -0
- package/models/trace/lantern/metrics/Interactive.d.ts +12 -0
- package/models/trace/lantern/metrics/Interactive.js +68 -0
- package/models/trace/lantern/metrics/Interactive.js.map +1 -0
- package/models/trace/lantern/metrics/LargestContentfulPaint.d.ts +16 -0
- package/models/trace/lantern/metrics/LargestContentfulPaint.js +70 -0
- package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -0
- package/models/trace/lantern/metrics/MaxPotentialFID.d.ts +14 -0
- package/models/trace/lantern/metrics/MaxPotentialFID.js +49 -0
- package/models/trace/lantern/metrics/MaxPotentialFID.js.map +1 -0
- package/models/trace/lantern/metrics/Metric.d.ts +26 -0
- package/models/trace/lantern/metrics/Metric.js +71 -0
- package/models/trace/lantern/metrics/Metric.js.map +1 -0
- package/models/trace/lantern/metrics/SpeedIndex.d.ts +25 -0
- package/models/trace/lantern/metrics/SpeedIndex.js +102 -0
- package/models/trace/lantern/metrics/SpeedIndex.js.map +1 -0
- package/models/trace/lantern/metrics/TBTUtils.d.ts +31 -0
- package/models/trace/lantern/metrics/TBTUtils.js +65 -0
- package/models/trace/lantern/metrics/TBTUtils.js.map +1 -0
- package/models/trace/lantern/metrics/TotalBlockingTime.d.ts +16 -0
- package/models/trace/lantern/metrics/TotalBlockingTime.js +79 -0
- package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -0
- package/models/trace/lantern/metrics/metrics.d.ts +15 -0
- package/models/trace/lantern/metrics/metrics.js +12 -0
- package/models/trace/lantern/metrics/metrics.js.map +1 -0
- package/models/trace/lantern/simulation/ConnectionPool.d.ts +26 -0
- package/models/trace/lantern/simulation/ConnectionPool.js +116 -0
- package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -0
- package/models/trace/lantern/simulation/Constants.d.ts +31 -0
- package/models/trace/lantern/simulation/Constants.js +43 -0
- package/models/trace/lantern/simulation/Constants.js.map +1 -0
- package/models/trace/lantern/simulation/DNSCache.d.ts +22 -0
- package/models/trace/lantern/simulation/DNSCache.js +48 -0
- package/models/trace/lantern/simulation/DNSCache.js.map +1 -0
- package/models/trace/lantern/simulation/NetworkAnalyzer.d.ts +112 -0
- package/models/trace/lantern/simulation/NetworkAnalyzer.js +486 -0
- package/models/trace/lantern/simulation/NetworkAnalyzer.js.map +1 -0
- package/models/trace/lantern/simulation/SimulationTimingMap.d.ts +71 -0
- package/models/trace/lantern/simulation/SimulationTimingMap.js +134 -0
- package/models/trace/lantern/simulation/SimulationTimingMap.js.map +1 -0
- package/models/trace/lantern/simulation/Simulator.d.ts +82 -0
- package/models/trace/lantern/simulation/Simulator.js +449 -0
- package/models/trace/lantern/simulation/Simulator.js.map +1 -0
- package/models/trace/lantern/simulation/TCPConnection.d.ts +48 -0
- package/models/trace/lantern/simulation/TCPConnection.js +158 -0
- package/models/trace/lantern/simulation/TCPConnection.js.map +1 -0
- package/models/trace/lantern/simulation/simulation.d.ts +21 -0
- package/models/trace/lantern/simulation/simulation.js +11 -0
- package/models/trace/lantern/simulation/simulation.js.map +1 -0
- package/models/trace/lantern/types/lantern.d.ts +205 -0
- package/models/trace/lantern/types/lantern.js +5 -0
- package/models/trace/lantern/types/lantern.js.map +1 -0
- package/models/trace/root-causes/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -1
- package/models/trace/root-causes/root-causes-tsconfig.json +0 -1
- package/models/trace/trace-tsconfig.json +4 -1
- package/models/trace/trace.d.ts +3 -1
- package/models/trace/trace.js +3 -1
- package/models/trace/trace.js.map +1 -1
- package/models/trace/types/Extensions.d.ts +2 -3
- package/models/trace/types/Extensions.js +2 -11
- package/models/trace/types/Extensions.js.map +1 -1
- package/models/trace/types/File.d.ts +1 -0
- package/models/trace/types/File.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +49 -0
- package/models/trace/types/TraceEvents.js +33 -0
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -1
- package/models/trace/types/types-tsconfig.json +0 -1
- package/package.json +1 -1
- package/PAUL.readme.md +0 -5
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
const INITIAL_CONGESTION_WINDOW = 10;
|
|
5
|
+
const TCP_SEGMENT_SIZE = 1460;
|
|
6
|
+
class TCPConnection {
|
|
7
|
+
_warmed;
|
|
8
|
+
_ssl;
|
|
9
|
+
_h2;
|
|
10
|
+
_rtt;
|
|
11
|
+
_throughput;
|
|
12
|
+
_serverLatency;
|
|
13
|
+
_congestionWindow;
|
|
14
|
+
_h2OverflowBytesDownloaded;
|
|
15
|
+
constructor(rtt, throughput, serverLatency = 0, ssl = true, h2 = false) {
|
|
16
|
+
this._warmed = false;
|
|
17
|
+
this._ssl = ssl;
|
|
18
|
+
this._h2 = h2;
|
|
19
|
+
this._rtt = rtt;
|
|
20
|
+
this._throughput = throughput;
|
|
21
|
+
this._serverLatency = serverLatency;
|
|
22
|
+
this._congestionWindow = INITIAL_CONGESTION_WINDOW;
|
|
23
|
+
this._h2OverflowBytesDownloaded = 0;
|
|
24
|
+
}
|
|
25
|
+
static maximumSaturatedConnections(rtt, availableThroughput) {
|
|
26
|
+
const roundTripsPerSecond = 1000 / rtt;
|
|
27
|
+
const bytesPerRoundTrip = TCP_SEGMENT_SIZE;
|
|
28
|
+
const bytesPerSecond = roundTripsPerSecond * bytesPerRoundTrip;
|
|
29
|
+
const minimumThroughputRequiredPerRequest = bytesPerSecond * 8;
|
|
30
|
+
return Math.floor(availableThroughput / minimumThroughputRequiredPerRequest);
|
|
31
|
+
}
|
|
32
|
+
_computeMaximumCongestionWindowInSegments() {
|
|
33
|
+
const bytesPerSecond = this._throughput / 8;
|
|
34
|
+
const secondsPerRoundTrip = this._rtt / 1000;
|
|
35
|
+
const bytesPerRoundTrip = bytesPerSecond * secondsPerRoundTrip;
|
|
36
|
+
return Math.floor(bytesPerRoundTrip / TCP_SEGMENT_SIZE);
|
|
37
|
+
}
|
|
38
|
+
setThroughput(throughput) {
|
|
39
|
+
this._throughput = throughput;
|
|
40
|
+
}
|
|
41
|
+
setCongestionWindow(congestion) {
|
|
42
|
+
this._congestionWindow = congestion;
|
|
43
|
+
}
|
|
44
|
+
setWarmed(warmed) {
|
|
45
|
+
this._warmed = warmed;
|
|
46
|
+
}
|
|
47
|
+
isWarm() {
|
|
48
|
+
return this._warmed;
|
|
49
|
+
}
|
|
50
|
+
isH2() {
|
|
51
|
+
return this._h2;
|
|
52
|
+
}
|
|
53
|
+
get congestionWindow() {
|
|
54
|
+
return this._congestionWindow;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Sets the number of excess bytes that are available to this connection on future downloads, only
|
|
58
|
+
* applies to H2 connections.
|
|
59
|
+
*/
|
|
60
|
+
setH2OverflowBytesDownloaded(bytes) {
|
|
61
|
+
if (!this._h2) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._h2OverflowBytesDownloaded = bytes;
|
|
65
|
+
}
|
|
66
|
+
clone() {
|
|
67
|
+
return Object.assign(new TCPConnection(this._rtt, this._throughput), this);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Simulates a network download of a particular number of bytes over an optional maximum amount of time
|
|
71
|
+
* and returns information about the ending state.
|
|
72
|
+
*
|
|
73
|
+
* See https://hpbn.co/building-blocks-of-tcp/#three-way-handshake and
|
|
74
|
+
* https://hpbn.co/transport-layer-security-tls/#tls-handshake for details.
|
|
75
|
+
*/
|
|
76
|
+
simulateDownloadUntil(bytesToDownload, options) {
|
|
77
|
+
const { timeAlreadyElapsed = 0, maximumTimeToElapse = Infinity, dnsResolutionTime = 0 } = options || {};
|
|
78
|
+
if (this._warmed && this._h2) {
|
|
79
|
+
bytesToDownload -= this._h2OverflowBytesDownloaded;
|
|
80
|
+
}
|
|
81
|
+
const twoWayLatency = this._rtt;
|
|
82
|
+
const oneWayLatency = twoWayLatency / 2;
|
|
83
|
+
const maximumCongestionWindow = this._computeMaximumCongestionWindowInSegments();
|
|
84
|
+
let handshakeAndRequest = oneWayLatency;
|
|
85
|
+
if (!this._warmed) {
|
|
86
|
+
handshakeAndRequest =
|
|
87
|
+
// DNS lookup
|
|
88
|
+
dnsResolutionTime +
|
|
89
|
+
// SYN
|
|
90
|
+
oneWayLatency +
|
|
91
|
+
// SYN ACK
|
|
92
|
+
oneWayLatency +
|
|
93
|
+
// ACK + initial request
|
|
94
|
+
oneWayLatency +
|
|
95
|
+
// ClientHello/ServerHello assuming TLS False Start is enabled (https://istlsfastyet.com/#server-performance).
|
|
96
|
+
(this._ssl ? twoWayLatency : 0);
|
|
97
|
+
}
|
|
98
|
+
let roundTrips = Math.ceil(handshakeAndRequest / twoWayLatency);
|
|
99
|
+
let timeToFirstByte = handshakeAndRequest + this._serverLatency + oneWayLatency;
|
|
100
|
+
if (this._warmed && this._h2) {
|
|
101
|
+
timeToFirstByte = 0;
|
|
102
|
+
}
|
|
103
|
+
const timeElapsedForTTFB = Math.max(timeToFirstByte - timeAlreadyElapsed, 0);
|
|
104
|
+
const maximumDownloadTimeToElapse = maximumTimeToElapse - timeElapsedForTTFB;
|
|
105
|
+
let congestionWindow = Math.min(this._congestionWindow, maximumCongestionWindow);
|
|
106
|
+
let totalBytesDownloaded = 0;
|
|
107
|
+
if (timeElapsedForTTFB > 0) {
|
|
108
|
+
totalBytesDownloaded = congestionWindow * TCP_SEGMENT_SIZE;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
roundTrips = 0;
|
|
112
|
+
}
|
|
113
|
+
let downloadTimeElapsed = 0;
|
|
114
|
+
let bytesRemaining = bytesToDownload - totalBytesDownloaded;
|
|
115
|
+
while (bytesRemaining > 0 && downloadTimeElapsed <= maximumDownloadTimeToElapse) {
|
|
116
|
+
roundTrips++;
|
|
117
|
+
downloadTimeElapsed += twoWayLatency;
|
|
118
|
+
congestionWindow = Math.max(Math.min(maximumCongestionWindow, congestionWindow * 2), 1);
|
|
119
|
+
const bytesDownloadedInWindow = congestionWindow * TCP_SEGMENT_SIZE;
|
|
120
|
+
totalBytesDownloaded += bytesDownloadedInWindow;
|
|
121
|
+
bytesRemaining -= bytesDownloadedInWindow;
|
|
122
|
+
}
|
|
123
|
+
const timeElapsed = timeElapsedForTTFB + downloadTimeElapsed;
|
|
124
|
+
const extraBytesDownloaded = this._h2 ? Math.max(totalBytesDownloaded - bytesToDownload, 0) : 0;
|
|
125
|
+
const bytesDownloaded = Math.max(Math.min(totalBytesDownloaded, bytesToDownload), 0);
|
|
126
|
+
let connectionTiming;
|
|
127
|
+
if (!this._warmed) {
|
|
128
|
+
connectionTiming = {
|
|
129
|
+
dnsResolutionTime,
|
|
130
|
+
connectionTime: handshakeAndRequest - dnsResolutionTime,
|
|
131
|
+
sslTime: this._ssl ? twoWayLatency : undefined,
|
|
132
|
+
timeToFirstByte,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
else if (this._h2) {
|
|
136
|
+
// TODO: timing information currently difficult to model for warm h2 connections.
|
|
137
|
+
connectionTiming = {
|
|
138
|
+
timeToFirstByte,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
connectionTiming = {
|
|
143
|
+
connectionTime: handshakeAndRequest,
|
|
144
|
+
timeToFirstByte,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
roundTrips,
|
|
149
|
+
timeElapsed,
|
|
150
|
+
bytesDownloaded,
|
|
151
|
+
extraBytesDownloaded,
|
|
152
|
+
congestionWindow,
|
|
153
|
+
connectionTiming,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export { TCPConnection };
|
|
158
|
+
//# sourceMappingURL=TCPConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TCPConnection.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/TCPConnection.ts"],"names":[],"mappings":"AAAA,4D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AAW;YACX,eAAe;YACf,oBAAoB;YACpB,gBAAgB;YAChB,gBAAgB;SACjB,CAAC;IACJ,CAAC;CACF;AAED,OAAO,EAAC,aAAa,EAAC,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 {type ConnectionTiming} from './SimulationTimingMap.js';\n\ninterface DownloadOptions {\n dnsResolutionTime?: number;\n timeAlreadyElapsed?: number;\n maximumTimeToElapse?: number;\n}\n\ninterface DownloadResults {\n roundTrips: number;\n timeElapsed: number;\n bytesDownloaded: number;\n extraBytesDownloaded: number;\n congestionWindow: number;\n connectionTiming: ConnectionTiming;\n}\n\nconst INITIAL_CONGESTION_WINDOW = 10;\nconst TCP_SEGMENT_SIZE = 1460;\n\nclass TCPConnection {\n _warmed: boolean;\n _ssl: boolean;\n _h2: boolean;\n _rtt: number;\n _throughput: number;\n _serverLatency: number;\n _congestionWindow: number;\n _h2OverflowBytesDownloaded: number;\n\n constructor(rtt: number, throughput: number, serverLatency = 0, ssl = true, h2 = false) {\n this._warmed = false;\n this._ssl = ssl;\n this._h2 = h2;\n this._rtt = rtt;\n this._throughput = throughput;\n this._serverLatency = serverLatency;\n this._congestionWindow = INITIAL_CONGESTION_WINDOW;\n this._h2OverflowBytesDownloaded = 0;\n }\n\n static maximumSaturatedConnections(rtt: number, availableThroughput: number): number {\n const roundTripsPerSecond = 1000 / rtt;\n const bytesPerRoundTrip = TCP_SEGMENT_SIZE;\n const bytesPerSecond = roundTripsPerSecond * bytesPerRoundTrip;\n const minimumThroughputRequiredPerRequest = bytesPerSecond * 8;\n return Math.floor(availableThroughput / minimumThroughputRequiredPerRequest);\n }\n\n _computeMaximumCongestionWindowInSegments(): number {\n const bytesPerSecond = this._throughput / 8;\n const secondsPerRoundTrip = this._rtt / 1000;\n const bytesPerRoundTrip = bytesPerSecond * secondsPerRoundTrip;\n return Math.floor(bytesPerRoundTrip / TCP_SEGMENT_SIZE);\n }\n\n setThroughput(throughput: number): void {\n this._throughput = throughput;\n }\n\n setCongestionWindow(congestion: number): void {\n this._congestionWindow = congestion;\n }\n\n setWarmed(warmed: boolean): void {\n this._warmed = warmed;\n }\n\n isWarm(): boolean {\n return this._warmed;\n }\n\n isH2(): boolean {\n return this._h2;\n }\n\n get congestionWindow(): number {\n return this._congestionWindow;\n }\n\n /**\n * Sets the number of excess bytes that are available to this connection on future downloads, only\n * applies to H2 connections.\n */\n setH2OverflowBytesDownloaded(bytes: number): void {\n if (!this._h2) {\n return;\n }\n this._h2OverflowBytesDownloaded = bytes;\n }\n\n clone(): TCPConnection {\n return Object.assign(new TCPConnection(this._rtt, this._throughput), this);\n }\n\n /**\n * Simulates a network download of a particular number of bytes over an optional maximum amount of time\n * and returns information about the ending state.\n *\n * See https://hpbn.co/building-blocks-of-tcp/#three-way-handshake and\n * https://hpbn.co/transport-layer-security-tls/#tls-handshake for details.\n */\n simulateDownloadUntil(bytesToDownload: number, options?: DownloadOptions): DownloadResults {\n const {timeAlreadyElapsed = 0, maximumTimeToElapse = Infinity, dnsResolutionTime = 0} = options || {};\n\n if (this._warmed && this._h2) {\n bytesToDownload -= this._h2OverflowBytesDownloaded;\n }\n const twoWayLatency = this._rtt;\n const oneWayLatency = twoWayLatency / 2;\n const maximumCongestionWindow = this._computeMaximumCongestionWindowInSegments();\n\n let handshakeAndRequest = oneWayLatency;\n if (!this._warmed) {\n handshakeAndRequest =\n // DNS lookup\n dnsResolutionTime +\n // SYN\n oneWayLatency +\n // SYN ACK\n oneWayLatency +\n // ACK + initial request\n oneWayLatency +\n // ClientHello/ServerHello assuming TLS False Start is enabled (https://istlsfastyet.com/#server-performance).\n (this._ssl ? twoWayLatency : 0);\n }\n\n let roundTrips = Math.ceil(handshakeAndRequest / twoWayLatency);\n let timeToFirstByte = handshakeAndRequest + this._serverLatency + oneWayLatency;\n if (this._warmed && this._h2) {\n timeToFirstByte = 0;\n }\n\n const timeElapsedForTTFB = Math.max(timeToFirstByte - timeAlreadyElapsed, 0);\n const maximumDownloadTimeToElapse = maximumTimeToElapse - timeElapsedForTTFB;\n\n let congestionWindow = Math.min(this._congestionWindow, maximumCongestionWindow);\n let totalBytesDownloaded = 0;\n if (timeElapsedForTTFB > 0) {\n totalBytesDownloaded = congestionWindow * TCP_SEGMENT_SIZE;\n } else {\n roundTrips = 0;\n }\n\n let downloadTimeElapsed = 0;\n let bytesRemaining = bytesToDownload - totalBytesDownloaded;\n while (bytesRemaining > 0 && downloadTimeElapsed <= maximumDownloadTimeToElapse) {\n roundTrips++;\n downloadTimeElapsed += twoWayLatency;\n congestionWindow = Math.max(Math.min(maximumCongestionWindow, congestionWindow * 2), 1);\n\n const bytesDownloadedInWindow = congestionWindow * TCP_SEGMENT_SIZE;\n totalBytesDownloaded += bytesDownloadedInWindow;\n bytesRemaining -= bytesDownloadedInWindow;\n }\n\n const timeElapsed = timeElapsedForTTFB + downloadTimeElapsed;\n const extraBytesDownloaded = this._h2 ? Math.max(totalBytesDownloaded - bytesToDownload, 0) : 0;\n const bytesDownloaded = Math.max(Math.min(totalBytesDownloaded, bytesToDownload), 0);\n\n let connectionTiming: ConnectionTiming;\n if (!this._warmed) {\n connectionTiming = {\n dnsResolutionTime,\n connectionTime: handshakeAndRequest - dnsResolutionTime,\n sslTime: this._ssl ? twoWayLatency : undefined,\n timeToFirstByte,\n };\n } else if (this._h2) {\n // TODO: timing information currently difficult to model for warm h2 connections.\n connectionTiming = {\n timeToFirstByte,\n };\n } else {\n connectionTiming = {\n connectionTime: handshakeAndRequest,\n timeToFirstByte,\n };\n }\n\n return {\n roundTrips,\n timeElapsed,\n bytesDownloaded,\n extraBytesDownloaded,\n congestionWindow,\n connectionTiming,\n };\n }\n}\n\nexport {TCPConnection};\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type AnyNetworkObject, type Simulation } from '../types/lantern.js';
|
|
7
|
+
export { ConnectionPool } from './ConnectionPool.js';
|
|
8
|
+
export { Constants } from './Constants.js';
|
|
9
|
+
export { DNSCache } from './DNSCache.js';
|
|
10
|
+
export { NetworkAnalyzer } from './NetworkAnalyzer.js';
|
|
11
|
+
export { SimulatorTimingMap, type CompleteNodeTiming } from './SimulationTimingMap.js';
|
|
12
|
+
export { Simulator } from './Simulator.js';
|
|
13
|
+
export { TCPConnection } from './TCPConnection.js';
|
|
14
|
+
export type MetricCoefficients = Simulation.MetricCoefficients;
|
|
15
|
+
export type MetricComputationDataInput = Simulation.MetricComputationDataInput;
|
|
16
|
+
export type NodeTiming = Simulation.NodeTiming;
|
|
17
|
+
export type Options = Simulation.Options;
|
|
18
|
+
export type ProcessedNavigation = Simulation.ProcessedNavigation;
|
|
19
|
+
export type Result<T = AnyNetworkObject> = Simulation.Result<T>;
|
|
20
|
+
export type Settings = Simulation.Settings;
|
|
21
|
+
export type URL = Simulation.URL;
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export { ConnectionPool } from './ConnectionPool.js';
|
|
5
|
+
export { Constants } from './Constants.js';
|
|
6
|
+
export { DNSCache } from './DNSCache.js';
|
|
7
|
+
export { NetworkAnalyzer } from './NetworkAnalyzer.js';
|
|
8
|
+
export { SimulatorTimingMap } from './SimulationTimingMap.js';
|
|
9
|
+
export { Simulator } from './Simulator.js';
|
|
10
|
+
export { TCPConnection } from './TCPConnection.js';
|
|
11
|
+
//# sourceMappingURL=simulation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulation.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/simulation.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAU7B,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAC,kBAAkB,EAA0B,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,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\n/**\n * @license\n * Copyright 2024 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {type AnyNetworkObject, type Simulation} from '../types/lantern.js';\n\nexport {ConnectionPool} from './ConnectionPool.js';\nexport {Constants} from './Constants.js';\nexport {DNSCache} from './DNSCache.js';\nexport {NetworkAnalyzer} from './NetworkAnalyzer.js';\nexport {SimulatorTimingMap, type CompleteNodeTiming} from './SimulationTimingMap.js';\nexport {Simulator} from './Simulator.js';\nexport {TCPConnection} from './TCPConnection.js';\n\nexport type MetricCoefficients = Simulation.MetricCoefficients;\nexport type MetricComputationDataInput = Simulation.MetricComputationDataInput;\nexport type NodeTiming = Simulation.NodeTiming;\nexport type Options = Simulation.Options;\nexport type ProcessedNavigation = Simulation.ProcessedNavigation;\nexport type Result<T = AnyNetworkObject> = Simulation.Result<T>;\nexport type Settings = Simulation.Settings;\nexport type URL = Simulation.URL;\n"]}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type * as Protocol from '../../../../generated/protocol.js';
|
|
2
|
+
import { type Node } from '../BaseNode.js';
|
|
3
|
+
import { type Simulator } from '../simulation/Simulator.js';
|
|
4
|
+
export type TraceEvent = {
|
|
5
|
+
name: string;
|
|
6
|
+
args: {
|
|
7
|
+
name?: string;
|
|
8
|
+
data?: {
|
|
9
|
+
frame?: string;
|
|
10
|
+
readyState?: number;
|
|
11
|
+
stackTrace?: {
|
|
12
|
+
url: string;
|
|
13
|
+
}[];
|
|
14
|
+
url?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
pid: number;
|
|
18
|
+
tid: number;
|
|
19
|
+
/** Timestamp of the event in microseconds. */
|
|
20
|
+
ts: number;
|
|
21
|
+
dur: number;
|
|
22
|
+
};
|
|
23
|
+
export type Trace = {
|
|
24
|
+
traceEvents: TraceEvent[];
|
|
25
|
+
};
|
|
26
|
+
export type ResourcePriority = ('VeryLow' | 'Low' | 'Medium' | 'High' | 'VeryHigh');
|
|
27
|
+
export type ResourceType = ('Document' | 'Stylesheet' | 'Image' | 'Media' | 'Font' | 'Script' | 'TextTrack' | 'XHR' | 'Fetch' | 'Prefetch' | 'EventSource' | 'WebSocket' | 'Manifest' | 'SignedExchange' | 'Ping' | 'CSPViolationReport' | 'Preflight' | 'Other');
|
|
28
|
+
type InitiatorType = ('parser' | 'script' | 'preload' | 'SignedExchange' | 'preflight' | 'other');
|
|
29
|
+
export type ResourceTiming = Protocol.Network.ResourceTiming;
|
|
30
|
+
type CallStack = {
|
|
31
|
+
callFrames: Array<{
|
|
32
|
+
scriptId: string;
|
|
33
|
+
url: string;
|
|
34
|
+
lineNumber: number;
|
|
35
|
+
columnNumber: number;
|
|
36
|
+
functionName: string;
|
|
37
|
+
}>;
|
|
38
|
+
parent?: CallStack;
|
|
39
|
+
};
|
|
40
|
+
export type ParsedURL = {
|
|
41
|
+
/**
|
|
42
|
+
* Equivalent to a `new URL(url).protocol` BUT w/o the trailing colon (:)
|
|
43
|
+
*/
|
|
44
|
+
scheme: string;
|
|
45
|
+
/**
|
|
46
|
+
* Equivalent to a `new URL(url).hostname`
|
|
47
|
+
*/
|
|
48
|
+
host: string;
|
|
49
|
+
securityOrigin: string;
|
|
50
|
+
};
|
|
51
|
+
export type AnyNetworkObject = any;
|
|
52
|
+
export type NetworkRequest<T = AnyNetworkObject> = {
|
|
53
|
+
requestId: string;
|
|
54
|
+
connectionId: number;
|
|
55
|
+
connectionReused: boolean;
|
|
56
|
+
url: string;
|
|
57
|
+
protocol: string;
|
|
58
|
+
parsedURL: ParsedURL;
|
|
59
|
+
documentURL: string;
|
|
60
|
+
/** When the renderer process initially discovers a network request, in milliseconds. */
|
|
61
|
+
rendererStartTime: number;
|
|
62
|
+
/**
|
|
63
|
+
* When the network service is about to handle a request, ie. just before going to the
|
|
64
|
+
* HTTP cache or going to the network for DNS/connection setup, in milliseconds.
|
|
65
|
+
*/
|
|
66
|
+
networkRequestTime: number;
|
|
67
|
+
/**
|
|
68
|
+
* When the last byte of the response headers is received, in milliseconds.
|
|
69
|
+
* Equal to networkRequestTime if no data is recieved over the
|
|
70
|
+
* network (ex: cached requests or data urls).
|
|
71
|
+
*/
|
|
72
|
+
responseHeadersEndTime: number;
|
|
73
|
+
/** When the last byte of the response body is received, in milliseconds. */
|
|
74
|
+
networkEndTime: number;
|
|
75
|
+
transferSize: number;
|
|
76
|
+
resourceSize: number;
|
|
77
|
+
fromDiskCache: boolean;
|
|
78
|
+
fromMemoryCache: boolean;
|
|
79
|
+
isLinkPreload: boolean;
|
|
80
|
+
finished: boolean;
|
|
81
|
+
failed: boolean;
|
|
82
|
+
statusCode: number;
|
|
83
|
+
/** The network request that redirected to this one */
|
|
84
|
+
redirectSource: NetworkRequest<T> | undefined;
|
|
85
|
+
/** The network request that this one redirected to */
|
|
86
|
+
redirectDestination: NetworkRequest<T> | undefined;
|
|
87
|
+
initiator: {
|
|
88
|
+
type: InitiatorType;
|
|
89
|
+
url?: string;
|
|
90
|
+
stack?: CallStack;
|
|
91
|
+
};
|
|
92
|
+
initiatorRequest: NetworkRequest<T> | undefined;
|
|
93
|
+
/** The chain of network requests that redirected to this one */
|
|
94
|
+
redirects: NetworkRequest[] | undefined;
|
|
95
|
+
timing: Protocol.Network.ResourceTiming | undefined;
|
|
96
|
+
resourceType: ResourceType | undefined;
|
|
97
|
+
mimeType: string;
|
|
98
|
+
priority: ResourcePriority;
|
|
99
|
+
frameId: string | undefined;
|
|
100
|
+
fromWorker: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Optional value for how long the server took to respond to this request.
|
|
103
|
+
* When not provided, the server response time is derived from the timing object.
|
|
104
|
+
*/
|
|
105
|
+
serverResponseTime?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Implementation-specific canoncial data structure that this Lantern NetworkRequest
|
|
108
|
+
* was derived from.
|
|
109
|
+
* Users of Lantern create a NetworkRequest matching this interface,
|
|
110
|
+
* but can store the source-of-truth for their network model in this property.
|
|
111
|
+
* This is then accessible as a read-only property on NetworkNode.
|
|
112
|
+
*/
|
|
113
|
+
rawRequest?: T;
|
|
114
|
+
};
|
|
115
|
+
export declare namespace Simulation {
|
|
116
|
+
interface URL {
|
|
117
|
+
/** URL of the initially requested URL */
|
|
118
|
+
requestedUrl?: string;
|
|
119
|
+
/** URL of the last document request */
|
|
120
|
+
mainDocumentUrl?: string;
|
|
121
|
+
}
|
|
122
|
+
/** Simulation settings that control the amount of network & cpu throttling in the run. */
|
|
123
|
+
interface ThrottlingSettings {
|
|
124
|
+
/** The round trip time in milliseconds. */
|
|
125
|
+
rttMs?: number;
|
|
126
|
+
/** The network throughput in kilobits per second. */
|
|
127
|
+
throughputKbps?: number;
|
|
128
|
+
/** The network request latency in milliseconds. */
|
|
129
|
+
requestLatencyMs?: number;
|
|
130
|
+
/** The network download throughput in kilobits per second. */
|
|
131
|
+
downloadThroughputKbps?: number;
|
|
132
|
+
/** The network upload throughput in kilobits per second. */
|
|
133
|
+
uploadThroughputKbps?: number;
|
|
134
|
+
/** The amount of slowdown applied to the cpu (1/<cpuSlowdownMultiplier>). */
|
|
135
|
+
cpuSlowdownMultiplier?: number;
|
|
136
|
+
}
|
|
137
|
+
interface PrecomputedLanternData {
|
|
138
|
+
additionalRttByOrigin: {
|
|
139
|
+
[origin: string]: number;
|
|
140
|
+
};
|
|
141
|
+
serverResponseTimeByOrigin: {
|
|
142
|
+
[origin: string]: number;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
interface Settings {
|
|
146
|
+
networkAnalysis: {
|
|
147
|
+
rtt: number;
|
|
148
|
+
additionalRttByOrigin: Map<string, number>;
|
|
149
|
+
serverResponseTimeByOrigin: Map<string, number>;
|
|
150
|
+
throughput: number;
|
|
151
|
+
};
|
|
152
|
+
/** The method used to throttle the network. */
|
|
153
|
+
throttlingMethod: 'devtools' | 'simulate' | 'provided';
|
|
154
|
+
/** The throttling config settings. */
|
|
155
|
+
throttling: Required<ThrottlingSettings>;
|
|
156
|
+
/** Precomputed lantern estimates to use instead of observed analysis. */
|
|
157
|
+
precomputedLanternData?: PrecomputedLanternData | null;
|
|
158
|
+
}
|
|
159
|
+
interface Options {
|
|
160
|
+
rtt?: number;
|
|
161
|
+
throughput?: number;
|
|
162
|
+
observedThroughput: number;
|
|
163
|
+
maximumConcurrentRequests?: number;
|
|
164
|
+
cpuSlowdownMultiplier?: number;
|
|
165
|
+
layoutTaskMultiplier?: number;
|
|
166
|
+
additionalRttByOrigin?: Map<string, number>;
|
|
167
|
+
serverResponseTimeByOrigin?: Map<string, number>;
|
|
168
|
+
}
|
|
169
|
+
interface ProcessedNavigation {
|
|
170
|
+
timestamps: {
|
|
171
|
+
firstContentfulPaint: number;
|
|
172
|
+
largestContentfulPaint?: number;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
interface MetricComputationDataInput {
|
|
176
|
+
simulator: Simulator;
|
|
177
|
+
graph: Node<unknown>;
|
|
178
|
+
processedNavigation: ProcessedNavigation;
|
|
179
|
+
}
|
|
180
|
+
interface MetricCoefficients {
|
|
181
|
+
intercept: number;
|
|
182
|
+
optimistic: number;
|
|
183
|
+
pessimistic: number;
|
|
184
|
+
}
|
|
185
|
+
interface NodeTiming {
|
|
186
|
+
startTime: number;
|
|
187
|
+
endTime: number;
|
|
188
|
+
duration: number;
|
|
189
|
+
}
|
|
190
|
+
interface Result<T = AnyNetworkObject> {
|
|
191
|
+
timeInMs: number;
|
|
192
|
+
nodeTimings: Map<Node<T>, NodeTiming>;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
export declare namespace Metrics {
|
|
196
|
+
interface Result<T = AnyNetworkObject> {
|
|
197
|
+
timing: number;
|
|
198
|
+
timestamp?: never;
|
|
199
|
+
optimisticEstimate: Simulation.Result<T>;
|
|
200
|
+
pessimisticEstimate: Simulation.Result<T>;
|
|
201
|
+
optimisticGraph: Node<T>;
|
|
202
|
+
pessimisticGraph: Node<T>;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lantern.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/types/lantern.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B","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 type * as Protocol from '../../../../generated/protocol.js';\nimport {type Node} from '../BaseNode.js';\nimport {type Simulator} from '../simulation/Simulator.js';\n\nexport type TraceEvent = {\n name: string,\n args: {\n name?: string,\n data?: {\n frame?: string,\n readyState?: number,\n stackTrace?: {\n url: string,\n }[],\n url?: string,\n },\n },\n pid: number,\n tid: number,\n /** Timestamp of the event in microseconds. */\n ts: number,\n dur: number,\n};\nexport type Trace = {\n traceEvents: TraceEvent[],\n};\nexport type ResourcePriority = ('VeryLow'|'Low'|'Medium'|'High'|'VeryHigh');\nexport type ResourceType =\n ('Document'|'Stylesheet'|'Image'|'Media'|'Font'|'Script'|'TextTrack'|'XHR'|'Fetch'|'Prefetch'|'EventSource'|\n 'WebSocket'|'Manifest'|'SignedExchange'|'Ping'|'CSPViolationReport'|'Preflight'|'Other');\ntype InitiatorType = ('parser'|'script'|'preload'|'SignedExchange'|'preflight'|'other');\nexport type ResourceTiming = Protocol.Network.ResourceTiming;\ntype CallStack = {\n callFrames: Array<{\n scriptId: string,\n url: string,\n lineNumber: number,\n columnNumber: number,\n functionName: string,\n }>,\n parent?: CallStack,\n};\n\nexport type ParsedURL = {\n /**\n * Equivalent to a `new URL(url).protocol` BUT w/o the trailing colon (:)\n */\n scheme: string,\n /**\n * Equivalent to a `new URL(url).hostname`\n */\n host: string,\n securityOrigin: string,\n};\n\n// When Lantern NetworkRequests are constructed, the source-of-truth of the network record is given as `rawRequest`.\n// Internally Lantern doesn't care about the type of this field, so a default type is given to simplify internal code\n// by avoiding unnecessary typescript overhead.\n// If callers want to access the underlying network record, they are expected to make use of this generic on top-level\n// interfaces like Simulator.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyNetworkObject = any;\n\nexport type NetworkRequest<T = AnyNetworkObject> = {\n requestId: string,\n connectionId: number,\n connectionReused: boolean,\n url: string,\n protocol: string,\n parsedURL: ParsedURL,\n documentURL: string,\n /** When the renderer process initially discovers a network request, in milliseconds. */\n rendererStartTime: number,\n /**\n * When the network service is about to handle a request, ie. just before going to the\n * HTTP cache or going to the network for DNS/connection setup, in milliseconds.\n */\n networkRequestTime: number,\n /**\n * When the last byte of the response headers is received, in milliseconds.\n * Equal to networkRequestTime if no data is recieved over the\n * network (ex: cached requests or data urls).\n */\n responseHeadersEndTime: number,\n /** When the last byte of the response body is received, in milliseconds. */\n networkEndTime: number,\n transferSize: number,\n resourceSize: number,\n fromDiskCache: boolean,\n fromMemoryCache: boolean,\n isLinkPreload: boolean,\n finished: boolean,\n failed: boolean,\n statusCode: number,\n /** The network request that redirected to this one */\n redirectSource: NetworkRequest<T>|undefined,\n /** The network request that this one redirected to */\n redirectDestination: NetworkRequest<T>|undefined,\n // TODO: can't use Protocol.Network.Initiator because of type mismatch in Lighthouse initiator.\n initiator: {\n type: InitiatorType,\n url?: string,\n stack?: CallStack,\n },\n initiatorRequest: NetworkRequest<T>|undefined,\n /** The chain of network requests that redirected to this one */\n redirects: NetworkRequest[]|undefined,\n timing: Protocol.Network.ResourceTiming|undefined,\n resourceType: ResourceType|undefined,\n mimeType: string,\n priority: ResourcePriority,\n frameId: string|undefined,\n fromWorker: boolean,\n /**\n * Optional value for how long the server took to respond to this request.\n * When not provided, the server response time is derived from the timing object.\n */\n serverResponseTime?: number,\n /**\n * Implementation-specific canoncial data structure that this Lantern NetworkRequest\n * was derived from.\n * Users of Lantern create a NetworkRequest matching this interface,\n * but can store the source-of-truth for their network model in this property.\n * This is then accessible as a read-only property on NetworkNode.\n */\n rawRequest?: T,\n};\n\nexport namespace Simulation {\n export interface URL {\n /** URL of the initially requested URL */\n requestedUrl?: string;\n /** URL of the last document request */\n mainDocumentUrl?: string;\n }\n\n /** Simulation settings that control the amount of network & cpu throttling in the run. */\n export interface ThrottlingSettings {\n /** The round trip time in milliseconds. */\n rttMs?: number;\n /** The network throughput in kilobits per second. */\n throughputKbps?: number;\n // devtools settings\n /** The network request latency in milliseconds. */\n requestLatencyMs?: number;\n /** The network download throughput in kilobits per second. */\n downloadThroughputKbps?: number;\n /** The network upload throughput in kilobits per second. */\n uploadThroughputKbps?: number;\n // used by both\n /** The amount of slowdown applied to the cpu (1/<cpuSlowdownMultiplier>). */\n cpuSlowdownMultiplier?: number;\n }\n\n export interface PrecomputedLanternData {\n additionalRttByOrigin: {[origin: string]: number};\n serverResponseTimeByOrigin: {[origin: string]: number};\n }\n\n export interface Settings {\n networkAnalysis: {\n rtt: number,\n additionalRttByOrigin: Map<string, number>,\n serverResponseTimeByOrigin: Map<string, number>,\n throughput: number,\n };\n /** The method used to throttle the network. */\n throttlingMethod: 'devtools'|'simulate'|'provided';\n /** The throttling config settings. */\n throttling: Required<ThrottlingSettings>;\n /** Precomputed lantern estimates to use instead of observed analysis. */\n precomputedLanternData?: PrecomputedLanternData|null;\n }\n\n export interface Options {\n rtt?: number;\n throughput?: number;\n observedThroughput: number;\n maximumConcurrentRequests?: number;\n cpuSlowdownMultiplier?: number;\n layoutTaskMultiplier?: number;\n additionalRttByOrigin?: Map<string, number>;\n serverResponseTimeByOrigin?: Map<string, number>;\n }\n\n export interface ProcessedNavigation {\n timestamps: {\n firstContentfulPaint: number,\n largestContentfulPaint?: number,\n };\n }\n\n export interface MetricComputationDataInput {\n simulator: Simulator;\n graph: Node<unknown>;\n processedNavigation: ProcessedNavigation;\n }\n\n export interface MetricCoefficients {\n intercept: number;\n optimistic: number;\n pessimistic: number;\n }\n\n export interface NodeTiming {\n startTime: number;\n endTime: number;\n duration: number;\n }\n\n export interface Result<T = AnyNetworkObject> {\n timeInMs: number;\n nodeTimings: Map<Node<T>, NodeTiming>;\n }\n}\n\nexport namespace Metrics {\n export interface Result<T = AnyNetworkObject> {\n timing: number;\n timestamp?: never;\n optimisticEstimate: Simulation.Result<T>;\n pessimisticEstimate: Simulation.Result<T>;\n optimisticGraph: Node<T>;\n pessimisticGraph: Node<T>;\n }\n}\n"]}
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"../../../../../../../front_end/models/trace/root-causes/root-causes.ts",
|
|
33
33
|
"../../../../../../../front_end/legacy/legacy-defs.d.ts",
|
|
34
34
|
"../../../../../../../front_end/global_typings/global_defs.d.ts",
|
|
35
|
-
"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
|
|
36
35
|
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
|
|
37
36
|
],
|
|
38
37
|
"references": [
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"../../../../../../../front_end/models/trace/root-causes/RootCauses.ts",
|
|
34
34
|
"../../../../../../../front_end/legacy/legacy-defs.d.ts",
|
|
35
35
|
"../../../../../../../front_end/global_typings/global_defs.d.ts",
|
|
36
|
-
"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
|
|
37
36
|
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
|
|
38
37
|
],
|
|
39
38
|
"references": [
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"../../../../../../front_end/models/trace/EntriesFilter.ts",
|
|
33
|
+
"../../../../../../front_end/models/trace/LanternComputationData.ts",
|
|
33
34
|
"../../../../../../front_end/models/trace/ModelImpl.ts",
|
|
34
35
|
"../../../../../../front_end/models/trace/Processor.ts",
|
|
35
36
|
"../../../../../../front_end/models/trace/TracingManager.ts",
|
|
36
37
|
"../../../../../../front_end/legacy/legacy-defs.d.ts",
|
|
37
38
|
"../../../../../../front_end/global_typings/global_defs.d.ts",
|
|
38
|
-
"../../../../../../front_end/global_typings/request_idle_callback.d.ts",
|
|
39
39
|
"../../../../../../node_modules/@types/filesystem/index.d.ts"
|
|
40
40
|
],
|
|
41
41
|
"references": [
|
|
@@ -60,6 +60,9 @@
|
|
|
60
60
|
{
|
|
61
61
|
"path": "insights/bundle-tsconfig.json"
|
|
62
62
|
},
|
|
63
|
+
{
|
|
64
|
+
"path": "lantern/bundle-tsconfig.json"
|
|
65
|
+
},
|
|
63
66
|
{
|
|
64
67
|
"path": "root-causes/bundle-tsconfig.json"
|
|
65
68
|
},
|
package/models/trace/trace.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ import * as Extras from './extras/extras.js';
|
|
|
3
3
|
import * as Handlers from './handlers/handlers.js';
|
|
4
4
|
import * as Helpers from './helpers/helpers.js';
|
|
5
5
|
import * as Insights from './insights/insights.js';
|
|
6
|
+
import * as Lantern from './lantern/lantern.js';
|
|
7
|
+
import * as LanternComputationData from './LanternComputationData.js';
|
|
6
8
|
import * as TraceModel from './ModelImpl.js';
|
|
7
9
|
import * as Processor from './Processor.js';
|
|
8
10
|
import * as RootCauses from './root-causes/root-causes.js';
|
|
9
11
|
import * as TracingManager from './TracingManager.js';
|
|
10
12
|
import * as Types from './types/types.js';
|
|
11
|
-
export { EntriesFilter, Extras, Handlers, Helpers, Insights, Processor, RootCauses, TraceModel, TracingManager, Types, };
|
|
13
|
+
export { EntriesFilter, Extras, Handlers, Helpers, Insights, Lantern, LanternComputationData, Processor, RootCauses, TraceModel, TracingManager, Types, };
|
package/models/trace/trace.js
CHANGED
|
@@ -6,10 +6,12 @@ import * as Extras from './extras/extras.js';
|
|
|
6
6
|
import * as Handlers from './handlers/handlers.js';
|
|
7
7
|
import * as Helpers from './helpers/helpers.js';
|
|
8
8
|
import * as Insights from './insights/insights.js';
|
|
9
|
+
import * as Lantern from './lantern/lantern.js';
|
|
10
|
+
import * as LanternComputationData from './LanternComputationData.js';
|
|
9
11
|
import * as TraceModel from './ModelImpl.js';
|
|
10
12
|
import * as Processor from './Processor.js';
|
|
11
13
|
import * as RootCauses from './root-causes/root-causes.js';
|
|
12
14
|
import * as TracingManager from './TracingManager.js';
|
|
13
15
|
import * as Types from './types/types.js';
|
|
14
|
-
export { EntriesFilter, Extras, Handlers, Helpers, Insights, Processor, RootCauses, TraceModel, TracingManager, Types, };
|
|
16
|
+
export { EntriesFilter, Extras, Handlers, Helpers, Insights, Lantern, LanternComputationData, Processor, RootCauses, TraceModel, TracingManager, Types, };
|
|
15
17
|
//# sourceMappingURL=trace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/trace.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EACL,aAAa,EACb,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,cAAc,EACd,KAAK,GACN,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 EntriesFilter from './EntriesFilter.js';\nimport * as Extras from './extras/extras.js';\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Insights from './insights/insights.js';\nimport * as TraceModel from './ModelImpl.js';\nimport * as Processor from './Processor.js';\nimport * as RootCauses from './root-causes/root-causes.js';\nimport * as TracingManager from './TracingManager.js';\nimport * as Types from './types/types.js';\n\nexport {\n EntriesFilter,\n Extras,\n Handlers,\n Helpers,\n Insights,\n Processor,\n RootCauses,\n TraceModel,\n TracingManager,\n Types,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/trace.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EACL,aAAa,EACb,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,sBAAsB,EACtB,SAAS,EACT,UAAU,EACV,UAAU,EACV,cAAc,EACd,KAAK,GACN,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 EntriesFilter from './EntriesFilter.js';\nimport * as Extras from './extras/extras.js';\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Insights from './insights/insights.js';\nimport * as Lantern from './lantern/lantern.js';\nimport * as LanternComputationData from './LanternComputationData.js';\nimport * as TraceModel from './ModelImpl.js';\nimport * as Processor from './Processor.js';\nimport * as RootCauses from './root-causes/root-causes.js';\nimport * as TracingManager from './TracingManager.js';\nimport * as Types from './types/types.js';\n\nexport {\n EntriesFilter,\n Extras,\n Handlers,\n Helpers,\n Insights,\n Lantern,\n LanternComputationData,\n Processor,\n RootCauses,\n TraceModel,\n TracingManager,\n Types,\n};\n"]}
|
|
@@ -16,7 +16,7 @@ export interface ExtensionFlameChartEntryPayload extends ExtensionDataPayload {
|
|
|
16
16
|
metadata: ExtensionDataPayload['metadata'] & {
|
|
17
17
|
dataType: ExtensionEntryType.TRACK_ENTRY;
|
|
18
18
|
};
|
|
19
|
-
color
|
|
19
|
+
color?: ExtensionColorFromPalette;
|
|
20
20
|
track: string;
|
|
21
21
|
detailsPairs?: [string, string][];
|
|
22
22
|
hintText?: string;
|
|
@@ -25,7 +25,7 @@ export interface ExtensionMarkerPayload extends ExtensionDataPayload {
|
|
|
25
25
|
metadata: ExtensionDataPayload['metadata'] & {
|
|
26
26
|
dataType: ExtensionEntryType.MARKER;
|
|
27
27
|
};
|
|
28
|
-
color
|
|
28
|
+
color?: ExtensionColorFromPalette;
|
|
29
29
|
detailsPairs?: [string, string][];
|
|
30
30
|
hintText?: string;
|
|
31
31
|
}
|
|
@@ -36,7 +36,6 @@ export interface SyntheticExtensionMarker extends SyntheticTraceEntry {
|
|
|
36
36
|
args: TraceEventArgs & ExtensionMarkerPayload;
|
|
37
37
|
}
|
|
38
38
|
export type SyntheticExtensionEntry = SyntheticExtensionFlameChartEntry | SyntheticExtensionMarker;
|
|
39
|
-
export declare function validateColorInPayload(payload: ExtensionDataPayload): boolean;
|
|
40
39
|
export declare function isExtensionPayloadMarker(payload: ExtensionDataPayload): payload is ExtensionMarkerPayload;
|
|
41
40
|
export declare function isExtensionPayloadFlameChartEntry(payload: ExtensionDataPayload): payload is ExtensionFlameChartEntryPayload;
|
|
42
41
|
export declare function isSyntheticExtensionEntry(entry: TraceEventData): entry is SyntheticExtensionEntry;
|
|
@@ -16,21 +16,12 @@ const extensionPalette = [
|
|
|
16
16
|
export function colorIsValid(color) {
|
|
17
17
|
return extensionPalette.includes(color);
|
|
18
18
|
}
|
|
19
|
-
export function validateColorInPayload(payload) {
|
|
20
|
-
if (!('color' in payload) || !payload.color) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
const color = payload['color'];
|
|
24
|
-
return colorIsValid(color);
|
|
25
|
-
}
|
|
26
19
|
export function isExtensionPayloadMarker(payload) {
|
|
27
|
-
|
|
28
|
-
return payload.metadata.dataType === "marker" /* ExtensionEntryType.MARKER */ && colorIsValid;
|
|
20
|
+
return payload.metadata.dataType === "marker" /* ExtensionEntryType.MARKER */;
|
|
29
21
|
}
|
|
30
22
|
export function isExtensionPayloadFlameChartEntry(payload) {
|
|
31
|
-
const colorIsValid = validateColorInPayload(payload);
|
|
32
23
|
const hasTrack = 'track' in payload && Boolean(payload.track);
|
|
33
|
-
return payload.metadata.dataType === "track-entry" /* ExtensionEntryType.TRACK_ENTRY */ && hasTrack
|
|
24
|
+
return payload.metadata.dataType === "track-entry" /* ExtensionEntryType.TRACK_ENTRY */ && hasTrack;
|
|
34
25
|
}
|
|
35
26
|
export function isSyntheticExtensionEntry(entry) {
|
|
36
27
|
return entry.cat === 'devtools.extension';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Extensions.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/Extensions.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAa7B,MAAM,gBAAgB,GAAG;IACvB,SAAS;IACT,eAAe;IACf,cAAc;IACd,WAAW;IACX,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,OAAO;CACC,CAAC;AAIX,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAQ,gBAAsC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AA8BD,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"Extensions.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/Extensions.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAa7B,MAAM,gBAAgB,GAAG;IACvB,SAAS;IACT,eAAe;IACf,cAAc;IACd,WAAW;IACX,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,OAAO;CACC,CAAC;AAIX,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAQ,gBAAsC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AA8BD,MAAM,UAAU,wBAAwB,CAAC,OAA6B;IACpE,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,6CAA8B,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,OAA6B;IAE7E,MAAM,QAAQ,GAAG,OAAO,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,uDAAmC,IAAI,QAAQ,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAqB;IAC7D,OAAO,KAAK,CAAC,GAAG,KAAK,oBAAoB,CAAC;AAC5C,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 {\n type SyntheticTraceEntry,\n type TraceEventArgs,\n type TraceEventData,\n} from './TraceEvents.js';\n\nexport const enum ExtensionEntryType {\n TRACK_ENTRY = 'track-entry',\n MARKER = 'marker',\n}\n\nconst extensionPalette = [\n 'primary',\n 'primary-light',\n 'primary-dark',\n 'secondary',\n 'secondary-light',\n 'secondary-dark',\n 'tertiary',\n 'tertiary-light',\n 'tertiary-dark',\n 'error',\n] as const;\n\nexport type ExtensionColorFromPalette = typeof extensionPalette[number];\n\nexport function colorIsValid(color: string): boolean {\n return (extensionPalette as readonly string[]).includes(color);\n}\n\nexport interface ExtensionDataPayload {\n metadata: {dataType: ExtensionEntryType, extensionName: string};\n}\nexport interface ExtensionFlameChartEntryPayload extends ExtensionDataPayload {\n metadata: ExtensionDataPayload['metadata']&{dataType: ExtensionEntryType.TRACK_ENTRY};\n color?: ExtensionColorFromPalette;\n track: string;\n detailsPairs?: [string, string][];\n hintText?: string;\n}\n\nexport interface ExtensionMarkerPayload extends ExtensionDataPayload {\n metadata: ExtensionDataPayload['metadata']&{dataType: ExtensionEntryType.MARKER};\n color?: ExtensionColorFromPalette;\n detailsPairs?: [string, string][];\n hintText?: string;\n}\n\nexport interface SyntheticExtensionFlameChartEntry extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionFlameChartEntryPayload;\n}\n\nexport interface SyntheticExtensionMarker extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionMarkerPayload;\n}\n\nexport type SyntheticExtensionEntry = SyntheticExtensionFlameChartEntry|SyntheticExtensionMarker;\n\nexport function isExtensionPayloadMarker(payload: ExtensionDataPayload): payload is ExtensionMarkerPayload {\n return payload.metadata.dataType === ExtensionEntryType.MARKER;\n}\n\nexport function isExtensionPayloadFlameChartEntry(payload: ExtensionDataPayload):\n payload is ExtensionFlameChartEntryPayload {\n const hasTrack = 'track' in payload && Boolean(payload.track);\n return payload.metadata.dataType === ExtensionEntryType.TRACK_ENTRY && hasTrack;\n}\n\nexport function isSyntheticExtensionEntry(entry: TraceEventData): entry is SyntheticExtensionEntry {\n return entry.cat === 'devtools.extension';\n}\n\n/**\n * Synthetic events created for extension tracks.\n */\nexport interface SyntheticExtensionFlameChartEntry extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionFlameChartEntryPayload;\n cat: 'devtools.extension';\n}\n\n/**\n * Synthetic events created for extension marks.\n */\nexport interface SyntheticExtensionMarker extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionMarkerPayload;\n cat: 'devtools.extension';\n}\n\nexport interface ExtensionTrackData {\n name: string;\n extensionName: string;\n flameChartEntries: SyntheticExtensionFlameChartEntry[];\n}\n"]}
|
|
@@ -58,6 +58,7 @@ export interface MetaData {
|
|
|
58
58
|
hardwareConcurrency?: number;
|
|
59
59
|
dataOrigin?: DataOrigin;
|
|
60
60
|
modifications?: Modifications;
|
|
61
|
+
enhancedTraceVersion?: number;
|
|
61
62
|
}
|
|
62
63
|
export type Contents = TraceFile | TraceEventData[];
|
|
63
64
|
export declare function traceEventKeyToValues(key: TraceEventSerializableKey): TraceEventSerializableKeyValues;
|