Skip to content

Commit

Permalink
report: sort performance audits based on impact (#15445)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianaixba authored Oct 3, 2023
1 parent 6a4c751 commit 896399b
Show file tree
Hide file tree
Showing 21 changed files with 1,101 additions and 548 deletions.
8 changes: 8 additions & 0 deletions cli/test/smokehouse/__snapshots__/report-assert-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ exports[`getAssertionReport works (multiple failing) 1`] = `
\\"numericValue\\": 0.13570762803819444,
\\"numericUnit\\": \\"unitless\\",
\\"displayValue\\": \\"0.136\\",
\\"scoringOptions\\": {
\\"p10\\": 0.1,
\\"median\\": 0.25
},
\\"details\\": {
\\"type\\": \\"debugdata\\",
\\"items\\": [
Expand All @@ -46,6 +50,10 @@ exports[`getAssertionReport works (trivial failing) 1`] = `
\\"numericValue\\": 0.13570762803819444,
\\"numericUnit\\": \\"unitless\\",
\\"displayValue\\": \\"0.136\\",
\\"scoringOptions\\": {
\\"p10\\": 0.1,
\\"median\\": 0.25
},
\\"details\\": {
\\"type\\": \\"debugdata\\",
\\"items\\": [
Expand Down
13 changes: 4 additions & 9 deletions core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import * as LH from '../../types/lh.js';
import {isUnderTest} from '../lib/lh-env.js';
import * as statistics from '../lib/statistics.js';
import {Util} from '../../shared/util.js';

const DEFAULT_PASS = 'defaultPass';
Expand Down Expand Up @@ -105,14 +104,7 @@ class Audit {
* @return {number}
*/
static computeLogNormalScore(controlPoints, value) {
let percentile = statistics.getLogNormalScore(controlPoints, value);
// Add a boost to scores of 90+, linearly ramping from 0 at 0.9 to half a
// point (0.005) at 1. Expands scores in (0.9, 1] to (0.9, 1.005], so more top
// scores will be a perfect 1 after the two-digit `Math.floor()` rounding below.
if (percentile > 0.9) { // getLogNormalScore ensures `percentile` can't exceed 1.
percentile += 0.05 * (percentile - 0.9);
}
return Math.floor(percentile * 100) / 100;
return Util.computeLogNormalScore(controlPoints, value);
}

/**
Expand Down Expand Up @@ -411,8 +403,11 @@ class Audit {
errorMessage: product.errorMessage,
errorStack: product.errorStack,
warnings: product.warnings,
scoringOptions: product.scoringOptions,
metricSavings: product.metricSavings,

details: product.details,
guidanceLevel: audit.meta.guidanceLevel,
};
}

Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/uses-long-cache-ttl.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import parseCacheControl from 'parse-cache-control';
import {Audit} from '../audit.js';
import {NetworkRequest} from '../../lib/network-request.js';
import UrlUtils from '../../lib/url-utils.js';
import {linearInterpolation} from '../../lib/statistics.js';
import {linearInterpolation} from '../../../shared/statistics.js';
import * as i18n from '../../lib/i18n/i18n.js';
import {NetworkRecords} from '../../computed/network-records.js';

Expand Down
5 changes: 4 additions & 1 deletion core/audits/metrics/cumulative-layout-shift.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ class CumulativeLayoutShift extends Audit {
items: [rest],
};

const scoringOptions = {p10: context.options.p10, median: context.options.median};

return {
score: Audit.computeLogNormalScore(
{p10: context.options.p10, median: context.options.median},
scoringOptions,
cumulativeLayoutShift
),
scoringOptions,
numericValue: cumulativeLayoutShift,
numericUnit: 'unitless',
displayValue: cumulativeLayoutShift.toLocaleString(context.settings.locale),
Expand Down
1 change: 1 addition & 0 deletions core/audits/metrics/first-contentful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class FirstContentfulPaint extends Audit {
options.scoring,
metricResult.timing
),
scoringOptions: options.scoring,
numericValue: metricResult.timing,
numericUnit: 'millisecond',
displayValue: str_(i18n.UIStrings.seconds, {timeInMs: metricResult.timing}),
Expand Down
1 change: 1 addition & 0 deletions core/audits/metrics/largest-contentful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class LargestContentfulPaint extends Audit {
options.scoring,
metricResult.timing
),
scoringOptions: options.scoring,
numericValue: metricResult.timing,
numericUnit: 'millisecond',
displayValue: str_(i18n.UIStrings.seconds, {timeInMs: metricResult.timing}),
Expand Down
1 change: 1 addition & 0 deletions core/audits/metrics/speed-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class SpeedIndex extends Audit {
options.scoring,
metricResult.timing
),
scoringOptions: options.scoring,
numericValue: metricResult.timing,
numericUnit: 'millisecond',
displayValue: str_(i18n.UIStrings.seconds, {timeInMs: metricResult.timing}),
Expand Down
1 change: 1 addition & 0 deletions core/audits/metrics/total-blocking-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class TotalBlockingTime extends Audit {
options.scoring,
metricResult.timing
),
scoringOptions: options.scoring,
numericValue: metricResult.timing,
numericUnit: 'millisecond',
displayValue: str_(i18n.UIStrings.ms, {timeInMs: metricResult.timing}),
Expand Down
Loading

1 comment on commit 896399b

@vercel
Copy link

@vercel vercel bot commented on 896399b Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lighthouse – ./

lighthouse-git-main-googlechrome.vercel.app
lighthouse-googlechrome.vercel.app

Please sign in to comment.