Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: use the same scoring curve for desktop in all channels #9911

Merged
merged 16 commits into from
Nov 10, 2019
27 changes: 18 additions & 9 deletions lighthouse-core/audits/metrics/first-contentful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,27 @@ class FirstContentfulPaint extends Audit {
title: str_(i18n.UIStrings.firstContentfulPaintMetric),
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces', 'devtoolsLogs'],
requiredArtifacts: ['traces', 'devtoolsLogs', 'TestedAsMobileDevice'],
};
}

/**
* @return {LH.Audit.ScoreOptions}
* @return {{mobile: LH.Audit.ScoreOptions, desktop: LH.Audit.ScoreOptions}}
*/
static get defaultOptions() {
return {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/2t1ugwykrl
scorePODR: 2000,
scoreMedian: 4000,
mobile: {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/2t1ugwykrl
scorePODR: 2000,
scoreMedian: 4000,
},
desktop: {
// SELECT QUANTILES(renderStart, 21) FROM [httparchive:summary_pages.2018_12_15_desktop] LIMIT 1000
scorePODR: 800,
scoreMedian: 1600,
},
};
}

Expand All @@ -54,12 +61,14 @@ class FirstContentfulPaint extends Audit {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricComputationData = {trace, devtoolsLog, settings: context.settings};
const metricResult = await ComputedFcp.request(metricComputationData, context);
const scoreOptions =
context.options[artifacts.TestedAsMobileDevice === false ? 'desktop' : 'mobile'];

return {
score: Audit.computeLogNormalScore(
metricResult.timing,
context.options.scorePODR,
context.options.scoreMedian
scoreOptions.scorePODR,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

probably should still note this as a breaking change in release notes, but this WFM 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agreed. we should adopt a way to signify breaking changes for release-notes-writing time.

scoreOptions.scoreMedian
),
numericValue: metricResult.timing,
displayValue: str_(i18n.UIStrings.seconds, {timeInMs: metricResult.timing}),
Expand Down
27 changes: 18 additions & 9 deletions lighthouse-core/audits/metrics/first-cpu-idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,27 @@ class FirstCPUIdle extends Audit {
title: str_(i18n.UIStrings.firstCPUIdleMetric),
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces', 'devtoolsLogs'],
requiredArtifacts: ['traces', 'devtoolsLogs', 'TestedAsMobileDevice'],
};
}

/**
* @return {LH.Audit.ScoreOptions}
* @return {{mobile: LH.Audit.ScoreOptions, desktop: LH.Audit.ScoreOptions}}
*/
static get defaultOptions() {
return {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/yv89gz2nwf
scorePODR: 2900,
scoreMedian: 6500,
mobile: {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/yv89gz2nwf
scorePODR: 2900,
scoreMedian: 6500,
},
desktop: {
// SELECT QUANTILES(fullyLoaded, 21) FROM [httparchive:summary_pages.2018_12_15_desktop] LIMIT 1000
scorePODR: 2000,
scoreMedian: 4500,
},
};
}

Expand All @@ -57,12 +64,14 @@ class FirstCPUIdle extends Audit {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricComputationData = {trace, devtoolsLog, settings: context.settings};
const metricResult = await ComputedFci.request(metricComputationData, context);
const scoreOptions =
context.options[artifacts.TestedAsMobileDevice === false ? 'desktop' : 'mobile'];

return {
score: Audit.computeLogNormalScore(
metricResult.timing,
context.options.scorePODR,
context.options.scoreMedian
scoreOptions.scorePODR,
scoreOptions.scoreMedian
),
numericValue: metricResult.timing,
displayValue: str_(i18n.UIStrings.seconds, {timeInMs: metricResult.timing}),
Expand Down
27 changes: 18 additions & 9 deletions lighthouse-core/audits/metrics/first-meaningful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,27 @@ class FirstMeaningfulPaint extends Audit {
title: str_(i18n.UIStrings.firstMeaningfulPaintMetric),
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces', 'devtoolsLogs'],
requiredArtifacts: ['traces', 'devtoolsLogs', 'TestedAsMobileDevice'],
};
}

/**
* @return {LH.Audit.ScoreOptions}
* @return {{mobile: LH.Audit.ScoreOptions, desktop: LH.Audit.ScoreOptions}}
*/
static get defaultOptions() {
return {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/2t1ugwykrl
scorePODR: 2000,
scoreMedian: 4000,
mobile: {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/2t1ugwykrl
scorePODR: 2000,
scoreMedian: 4000,
},
desktop: {
// SELECT QUANTILES(renderStart, 21) FROM [httparchive:summary_pages.2018_12_15_desktop] LIMIT 1000
scorePODR: 800,
scoreMedian: 1600,
},
};
}

Expand All @@ -57,12 +64,14 @@ class FirstMeaningfulPaint extends Audit {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricComputationData = {trace, devtoolsLog, settings: context.settings};
const metricResult = await ComputedFmp.request(metricComputationData, context);
const scoreOptions =
context.options[artifacts.TestedAsMobileDevice === false ? 'desktop' : 'mobile'];

return {
score: Audit.computeLogNormalScore(
metricResult.timing,
context.options.scorePODR,
context.options.scoreMedian
scoreOptions.scorePODR,
scoreOptions.scoreMedian
),
numericValue: metricResult.timing,
displayValue: str_(i18n.UIStrings.seconds, {timeInMs: metricResult.timing}),
Expand Down
27 changes: 18 additions & 9 deletions lighthouse-core/audits/metrics/interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,27 @@ class InteractiveMetric extends Audit {
title: str_(i18n.UIStrings.interactiveMetric),
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces', 'devtoolsLogs'],
requiredArtifacts: ['traces', 'devtoolsLogs', 'TestedAsMobileDevice'],
};
}

/**
* @return {LH.Audit.ScoreOptions}
* @return {{mobile: LH.Audit.ScoreOptions, desktop: LH.Audit.ScoreOptions}}
*/
static get defaultOptions() {
return {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/5xgy0pyrbp
scorePODR: 2900,
scoreMedian: 7300,
mobile: {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/5xgy0pyrbp
scorePODR: 2900,
scoreMedian: 7300,
},
desktop: {
// SELECT QUANTILES(fullyLoaded, 21) FROM [httparchive:summary_pages.2018_12_15_desktop] LIMIT 1000
scorePODR: 2000,
scoreMedian: 4500,
},
};
}

Expand All @@ -61,6 +68,8 @@ class InteractiveMetric extends Audit {
const metricComputationData = {trace, devtoolsLog, settings: context.settings};
const metricResult = await Interactive.request(metricComputationData, context);
const timeInMs = metricResult.timing;
const scoreOptions =
context.options[artifacts.TestedAsMobileDevice === false ? 'desktop' : 'mobile'];
const extendedInfo = {
timeInMs,
timestamp: metricResult.timestamp,
Expand All @@ -73,8 +82,8 @@ class InteractiveMetric extends Audit {
return {
score: Audit.computeLogNormalScore(
timeInMs,
context.options.scorePODR,
context.options.scoreMedian
scoreOptions.scorePODR,
scoreOptions.scoreMedian
),
numericValue: timeInMs,
displayValue: str_(i18n.UIStrings.seconds, {timeInMs}),
Expand Down
27 changes: 18 additions & 9 deletions lighthouse-core/audits/metrics/speed-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,27 @@ class SpeedIndex extends Audit {
title: str_(i18n.UIStrings.speedIndexMetric),
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces', 'devtoolsLogs'],
requiredArtifacts: ['traces', 'devtoolsLogs', 'TestedAsMobileDevice'],
};
}

/**
* @return {LH.Audit.ScoreOptions}
* @return {{mobile: LH.Audit.ScoreOptions, desktop: LH.Audit.ScoreOptions}}
*/
static get defaultOptions() {
return {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/orvoyu9ygq
scorePODR: 2900,
scoreMedian: 5800,
mobile: {
// 75th and 95th percentiles HTTPArchive -> median and PODR
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
// see https://www.desmos.com/calculator/orvoyu9ygq
scorePODR: 2900,
scoreMedian: 5800,
},
desktop: {
// SELECT QUANTILES(SpeedIndex, 21) FROM [httparchive:summary_pages.2018_12_15_desktop] LIMIT 1000
scorePODR: 1100,
scoreMedian: 2300,
},
};
}

Expand All @@ -56,12 +63,14 @@ class SpeedIndex extends Audit {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricComputationData = {trace, devtoolsLog, settings: context.settings};
const metricResult = await ComputedSi.request(metricComputationData, context);
const scoreOptions =
context.options[artifacts.TestedAsMobileDevice === false ? 'desktop' : 'mobile'];

return {
score: Audit.computeLogNormalScore(
metricResult.timing,
context.options.scorePODR,
context.options.scoreMedian
scoreOptions.scorePODR,
scoreOptions.scoreMedian
),
numericValue: metricResult.timing,
displayValue: str_(i18n.UIStrings.seconds, {timeInMs: metricResult.timing}),
Expand Down
13 changes: 0 additions & 13 deletions lighthouse-core/config/lr-desktop-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@ const config = {
// Skip the h2 audit so it doesn't lie to us. See https://github.com/GoogleChrome/lighthouse/issues/6539
skipAudits: ['uses-http2'],
},
audits: [
// 75th and 95th percentiles -> median and PODR
// SELECT QUANTILES(renderStart, 21) FROM [httparchive:summary_pages.2018_12_15_desktop] LIMIT 1000
{path: 'metrics/first-contentful-paint', options: {scorePODR: 800, scoreMedian: 1600}},
{path: 'metrics/first-meaningful-paint', options: {scorePODR: 800, scoreMedian: 1600}},
// 75th and 95th percentiles -> median and PODR
// SELECT QUANTILES(SpeedIndex, 21) FROM [httparchive:summary_pages.2018_12_15_desktop] LIMIT 1000
{path: 'metrics/speed-index', options: {scorePODR: 1100, scoreMedian: 2300}},
// 75th and 95th percentiles -> median and PODR
// SELECT QUANTILES(fullyLoaded, 21) FROM [httparchive:summary_pages.2018_12_15_desktop] LIMIT 1000
{path: 'metrics/interactive', options: {scorePODR: 2000, scoreMedian: 4500}},
{path: 'metrics/first-cpu-idle', options: {scorePODR: 2000, scoreMedian: 4500}},
],
};

module.exports = config;
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@ describe('Metrics: FCP', () => {
assert.ok(result.pessimisticGraph, 'should have created pessimistic graph');
});

it('should compute an observed value', async () => {
it('should compute an observed value (desktop)', async () => {
const settings = {throttlingMethod: 'provided'};
const context = {settings, computedCache: new Map()};
const result = await FirstContentfulPaint.request({trace, devtoolsLog, settings}, context);

assert.equal(Math.round(result.timing), 499);
assert.equal(result.timestamp, 225414670885);
});

it('should compute an observed value (mobile)', async () => {
const settings = {throttlingMethod: 'provided'};
const context = {settings, computedCache: new Map()};
const result = await FirstContentfulPaint.request(
{trace, devtoolsLog, settings, TestedAsMobileDevice: true}, context);

assert.equal(Math.round(result.timing), 499);
assert.equal(result.timestamp, 225414670885);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Metrics: FMP', () => {
assert.ok(result.pessimisticGraph, 'should have created pessimistic graph');
});

it('should compute an observed value', async () => {
it('should compute an observed value (desktop)', async () => {
settings = {throttlingMethod: 'provided'};
const context = {computedCache: new Map()};
const result = await FirstMeaningfulPaint.request({trace, devtoolsLog, settings}, context);
Expand All @@ -66,6 +66,16 @@ describe('Metrics: FMP', () => {
assert.equal(result.timestamp, 225414955343);
});

it('should compute an observed value (mobile)', async () => {
settings = {throttlingMethod: 'provided'};
const context = {computedCache: new Map()};
const result = await FirstMeaningfulPaint.request(
{trace, devtoolsLog, settings, TestedAsMobileDevice: true}, context);

assert.equal(Math.round(result.timing), 783);
assert.equal(result.timestamp, 225414955343);
});

it('handles cases when there was a tracingStartedInPage after navStart', async () => {
trace = lateTracingStartedTrace;
addEmptyTask();
Expand Down
12 changes: 11 additions & 1 deletion lighthouse-core/test/computed/metrics/interactive-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Metrics: TTI', () => {
assert.ok(result.pessimisticGraph, 'should have created pessimistic graph');
});

it('should compute an observed value', async () => {
it('should compute an observed value (desktop)', async () => {
const settings = {throttlingMethod: 'provided'};
const context = {settings, computedCache: new Map()};
const result = await Interactive.request({trace, devtoolsLog, settings}, context);
Expand All @@ -53,6 +53,16 @@ describe('Metrics: TTI', () => {
assert.equal(result.timestamp, 225415754204);
});

it('should compute an observed value (mobile)', async () => {
const settings = {throttlingMethod: 'provided'};
const context = {settings, computedCache: new Map()};
const result = await Interactive.request(
{trace, devtoolsLog, settings, TestedAsMobileDevice: true}, context);

assert.equal(Math.round(result.timing), 1582);
assert.equal(result.timestamp, 225415754204);
});

describe('#findOverlappingQuietPeriods', () => {
it('should return entire range when no activity is present', () => {
const navigationStart = 220023532;
Expand Down
12 changes: 11 additions & 1 deletion lighthouse-core/test/computed/metrics/speed-index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ describe('Metrics: Speed Index', () => {
}).toMatchSnapshot();
});

it('should compute an observed value', async () => {
it('should compute an observed value (desktop)', async () => {
const settings = {throttlingMethod: 'provided'};
const context = {settings, computedCache: new Map()};
const result = await SpeedIndex.request({trace, devtoolsLog, settings}, context);

assert.equal(result.timing, 605);
assert.equal(result.timestamp, 225414777015);
});

it('should compute an observed value (mobile)', async () => {
const settings = {throttlingMethod: 'provided'};
const context = {settings, computedCache: new Map()};
const result = await SpeedIndex.request(
{trace, devtoolsLog, settings, TestedAsMobileDevice: true}, context);

assert.equal(result.timing, 605);
assert.equal(result.timestamp, 225414777015);
});
});