lighthouse 11.7.0-dev.20240414 → 11.7.0-dev.20240415
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.
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import * as Lantern from '../types/lantern.js';
|
|
8
8
|
import {Metric} from '../metric.js';
|
|
9
9
|
import {BaseNode} from '../base-node.js';
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
const mobileSlow4GRtt = 150;
|
|
12
12
|
|
|
13
13
|
/** @typedef {import('../base-node.js').Node} Node */
|
|
14
14
|
|
|
@@ -44,7 +44,7 @@ class SpeedIndex extends Metric {
|
|
|
44
44
|
// lantern test data set. See core/scripts/test-lantern.sh for more detail.
|
|
45
45
|
// While the coefficients haven't been analyzed at the interpolated points, it's our current best effort.
|
|
46
46
|
const defaultCoefficients = this.COEFFICIENTS;
|
|
47
|
-
const defaultRttExcess =
|
|
47
|
+
const defaultRttExcess = mobileSlow4GRtt - 30;
|
|
48
48
|
const multiplier = Math.max((rttMs - 30) / defaultRttExcess, 0);
|
|
49
49
|
|
|
50
50
|
return {
|
|
@@ -140,15 +140,6 @@ class NetworkAnalyzer {
|
|
|
140
140
|
const {timing, connectionReused, record} = info;
|
|
141
141
|
if (connectionReused) return;
|
|
142
142
|
|
|
143
|
-
// In LR, network records are missing connection timing, but we've smuggled it in via headers.
|
|
144
|
-
if (global.isLightrider && record.lrStatistics) {
|
|
145
|
-
if (record.protocol.startsWith('h3')) {
|
|
146
|
-
return record.lrStatistics.TCPMs;
|
|
147
|
-
} else {
|
|
148
|
-
return [record.lrStatistics.TCPMs / 2, record.lrStatistics.TCPMs / 2];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
143
|
const {connectStart, sslStart, sslEnd, connectEnd} = timing;
|
|
153
144
|
if (connectEnd >= 0 && connectStart >= 0 && record.protocol.startsWith('h3')) {
|
|
154
145
|
// These values are equal to sslStart and sslEnd for h3.
|
|
@@ -256,9 +247,7 @@ class NetworkAnalyzer {
|
|
|
256
247
|
*/
|
|
257
248
|
static _estimateResponseTimeByOrigin(records, rttByOrigin) {
|
|
258
249
|
return NetworkAnalyzer._estimateValueByOrigin(records, ({record, timing}) => {
|
|
259
|
-
|
|
260
|
-
// close to the response time.
|
|
261
|
-
if (global.isLightrider && record.lrStatistics) return record.lrStatistics.requestMs;
|
|
250
|
+
if (record.serverResponseTime !== undefined) return record.serverResponseTime;
|
|
262
251
|
|
|
263
252
|
if (!Number.isFinite(timing.receiveHeadersEnd) || timing.receiveHeadersEnd < 0) return;
|
|
264
253
|
if (!Number.isFinite(timing.sendEnd) || timing.sendEnd < 0) return;
|
|
@@ -67,9 +67,6 @@ export class NetworkRequest<T = any> {
|
|
|
67
67
|
resourceSize: number;
|
|
68
68
|
fromDiskCache: boolean;
|
|
69
69
|
fromMemoryCache: boolean;
|
|
70
|
-
// TODO(15841): remove from lantern.
|
|
71
|
-
/** Extra timing information available only when run in Lightrider. */
|
|
72
|
-
lrStatistics: LightriderStatistics | undefined;
|
|
73
70
|
finished: boolean;
|
|
74
71
|
statusCode: number;
|
|
75
72
|
/** The network request that this one redirected to */
|
|
@@ -80,6 +77,11 @@ export class NetworkRequest<T = any> {
|
|
|
80
77
|
/** The chain of network requests that redirected to this one */
|
|
81
78
|
redirects: NetworkRequest[] | undefined;
|
|
82
79
|
timing: LH.Crdp.Network.ResourceTiming | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Optional value for how long the server took to respond to this request.
|
|
82
|
+
* When not provided, the server response time is derived from the timing object.
|
|
83
|
+
*/
|
|
84
|
+
serverResponseTime: number | undefined;
|
|
83
85
|
resourceType: LH.Crdp.Network.ResourceType | undefined;
|
|
84
86
|
mimeType: string;
|
|
85
87
|
priority: LH.Crdp.Network.ResourcePriority;
|
|
@@ -247,6 +247,7 @@ export class NetworkRequest {
|
|
|
247
247
|
* is passed in via X-Headers similar to 'X-TotalFetchedSize'.
|
|
248
248
|
*/
|
|
249
249
|
_updateTimingsForLightrider(): void;
|
|
250
|
+
serverResponseTime: number | undefined;
|
|
250
251
|
}
|
|
251
252
|
export namespace NetworkRequest {
|
|
252
253
|
export { HEADER_TCP };
|
|
@@ -536,6 +536,7 @@ class NetworkRequest {
|
|
|
536
536
|
requestMs: requestMs,
|
|
537
537
|
responseMs: responseMs,
|
|
538
538
|
};
|
|
539
|
+
this.serverResponseTime = responseMs;
|
|
539
540
|
}
|
|
540
541
|
|
|
541
542
|
/**
|
|
@@ -574,8 +575,35 @@ class NetworkRequest {
|
|
|
574
575
|
* @return {Lantern.NetworkRequest<NetworkRequest>}
|
|
575
576
|
*/
|
|
576
577
|
static asLanternNetworkRequest(record) {
|
|
578
|
+
// In LR, network records are missing connection timing, but we've smuggled it in via headers.
|
|
579
|
+
let timing = record.timing;
|
|
580
|
+
let serverResponseTime;
|
|
581
|
+
if (global.isLightrider && record.lrStatistics) {
|
|
582
|
+
if (record.protocol.startsWith('h3')) {
|
|
583
|
+
// @ts-expect-error We don't need all the properties set.
|
|
584
|
+
timing = {
|
|
585
|
+
connectStart: 0,
|
|
586
|
+
connectEnd: record.lrStatistics.TCPMs,
|
|
587
|
+
};
|
|
588
|
+
} else {
|
|
589
|
+
// @ts-expect-error We don't need all the properties set.
|
|
590
|
+
timing = {
|
|
591
|
+
connectStart: 0,
|
|
592
|
+
sslStart: record.lrStatistics.TCPMs / 2,
|
|
593
|
+
connectEnd: record.lrStatistics.TCPMs,
|
|
594
|
+
sslEnd: record.lrStatistics.TCPMs,
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
// Lightrider does not have timings for sendEnd, but we do have this timing which should be
|
|
598
|
+
// close to the response time.
|
|
599
|
+
serverResponseTime = record.lrStatistics.requestMs;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
577
603
|
return {
|
|
578
604
|
...record,
|
|
605
|
+
timing,
|
|
606
|
+
serverResponseTime,
|
|
579
607
|
record,
|
|
580
608
|
};
|
|
581
609
|
}
|
package/package.json
CHANGED