lighthouse 13.6.0-dev.20261118 → 13.6.0-dev.20261119
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.
|
@@ -81,6 +81,9 @@ declare namespace getOuterHTMLSnippet {
|
|
|
81
81
|
* - 800+ is a high-end Android phone, Galaxy S8, low-end Chromebook, etc
|
|
82
82
|
* - 125+ is a mid-tier Android phone, Moto G4, etc
|
|
83
83
|
* - <125 is a budget Android phone, Alcatel Ideal, Galaxy J2, etc
|
|
84
|
+
*
|
|
85
|
+
* Timing uses `performance.now()` rather than `Date.now()` because pages may freeze `Date`
|
|
86
|
+
* (e.g. mockdate or fake timers for deterministic tests), which would make these loops never end.
|
|
84
87
|
* @return {number}
|
|
85
88
|
*/
|
|
86
89
|
declare function computeBenchmarkIndex(): number;
|
|
@@ -178,6 +178,9 @@ function getOuterHTMLSnippet(element, ignoreAttrs = [], snippetCharacterLimit =
|
|
|
178
178
|
* - 800+ is a high-end Android phone, Galaxy S8, low-end Chromebook, etc
|
|
179
179
|
* - 125+ is a mid-tier Android phone, Moto G4, etc
|
|
180
180
|
* - <125 is a budget Android phone, Alcatel Ideal, Galaxy J2, etc
|
|
181
|
+
*
|
|
182
|
+
* Timing uses `performance.now()` rather than `Date.now()` because pages may freeze `Date`
|
|
183
|
+
* (e.g. mockdate or fake timers for deterministic tests), which would make these loops never end.
|
|
181
184
|
* @return {number}
|
|
182
185
|
*/
|
|
183
186
|
function computeBenchmarkIndex() {
|
|
@@ -188,10 +191,10 @@ function computeBenchmarkIndex() {
|
|
|
188
191
|
* used a string length of 100000 instead of 10000.
|
|
189
192
|
*/
|
|
190
193
|
function benchmarkIndexGC() {
|
|
191
|
-
const start =
|
|
194
|
+
const start = performance.now();
|
|
192
195
|
let iterations = 0;
|
|
193
196
|
|
|
194
|
-
while (
|
|
197
|
+
while (performance.now() - start < 500) {
|
|
195
198
|
let s = '';
|
|
196
199
|
for (let j = 0; j < 10000; j++) s += 'a';
|
|
197
200
|
if (s.length === 1) throw new Error('will never happen, but prevents compiler optimizations');
|
|
@@ -199,7 +202,7 @@ function computeBenchmarkIndex() {
|
|
|
199
202
|
iterations++;
|
|
200
203
|
}
|
|
201
204
|
|
|
202
|
-
const durationInSeconds = (
|
|
205
|
+
const durationInSeconds = (performance.now() - start) / 1000;
|
|
203
206
|
return Math.round(iterations / 10 / durationInSeconds);
|
|
204
207
|
}
|
|
205
208
|
|
|
@@ -213,14 +216,14 @@ function computeBenchmarkIndex() {
|
|
|
213
216
|
const arrB = [];
|
|
214
217
|
for (let i = 0; i < 100000; i++) arrA[i] = arrB[i] = i;
|
|
215
218
|
|
|
216
|
-
const start =
|
|
219
|
+
const start = performance.now();
|
|
217
220
|
let iterations = 0;
|
|
218
221
|
|
|
219
222
|
// Some Intel CPUs have a performance cliff due to unlucky JCC instruction alignment.
|
|
220
|
-
// Two possible fixes: call
|
|
221
|
-
// We'll call
|
|
223
|
+
// Two possible fixes: call performance.now less often, or manually unroll the inner loop a bit.
|
|
224
|
+
// We'll call performance.now less and only check the duration on every 10th iteration for simplicity.
|
|
222
225
|
// See https://bugs.chromium.org/p/v8/issues/detail?id=10954#c1.
|
|
223
|
-
while (iterations % 10 !== 0 ||
|
|
226
|
+
while (iterations % 10 !== 0 || performance.now() - start < 500) {
|
|
224
227
|
const src = iterations % 2 === 0 ? arrA : arrB;
|
|
225
228
|
const tgt = iterations % 2 === 0 ? arrB : arrA;
|
|
226
229
|
|
|
@@ -229,7 +232,7 @@ function computeBenchmarkIndex() {
|
|
|
229
232
|
iterations++;
|
|
230
233
|
}
|
|
231
234
|
|
|
232
|
-
const durationInSeconds = (
|
|
235
|
+
const durationInSeconds = (performance.now() - start) / 1000;
|
|
233
236
|
return Math.round(iterations / 10 / durationInSeconds);
|
|
234
237
|
}
|
|
235
238
|
|
|
@@ -422,13 +425,13 @@ function wrapRequestIdleCallback(cpuSlowdownMultiplier) {
|
|
|
422
425
|
* @type {Parameters<typeof window['requestIdleCallback']>[0]}
|
|
423
426
|
*/
|
|
424
427
|
const cbWrap = (deadline) => {
|
|
425
|
-
const start =
|
|
428
|
+
const start = performance.now();
|
|
426
429
|
// @ts-expect-error - save original on non-standard property.
|
|
427
430
|
deadline.__timeRemaining = deadline.timeRemaining;
|
|
428
431
|
deadline.timeRemaining = () => {
|
|
429
432
|
// @ts-expect-error - access non-standard property.
|
|
430
433
|
const timeRemaining = deadline.__timeRemaining();
|
|
431
|
-
return Math.min(timeRemaining, Math.max(0, maxExecutionTimeMs - (
|
|
434
|
+
return Math.min(timeRemaining, Math.max(0, maxExecutionTimeMs - (performance.now() - start))
|
|
432
435
|
);
|
|
433
436
|
};
|
|
434
437
|
deadline.timeRemaining.toString = () => {
|
package/package.json
CHANGED