[go: nahoru, domu]

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

new_audit: add TTI Companion Metric to JSON #8975

Merged
merged 14 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address comments by brendankenny
  • Loading branch information
deepanjanroy committed Jun 4, 2019
commit ebbc7062e2f2467a077be827a3fb1ac3279f0b65
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class CumulativeLongQueuingDelay extends ComputedMetric {
// optimizing to reach FCP as fast as possible without having to worry about task lengths.
//
// TTI is picked as the upper bound because we want a well defined end point so that the
// metric does not rely on how long we trace. There is very low probability of encountering a
// Long Queuing Delay region past TTI.
// metric does not rely on how long we trace.
if (region.end < fcpTimeInMs) continue;
patrickhulce marked this conversation as resolved.
Show resolved Hide resolved
if (region.start > interactiveTimeMs) continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ class LanternCumulativeLongQueuingDelay extends LanternMetric {
* @return {LH.Gatherer.Simulation.Result}
*/
static getEstimateFromSimulation(simulation, extras) {
// Intentionally use the opposite FCP estimate, a more pessimistic FCP means that more tasks are
// excluded from the CumulativeLongQueuingDelay computation, so a higher FCP means lower value
// for the same work.
// Intentionally use the opposite FCP estimate. A pessimistic FCP is higher than equal to an
// optimistic FCP, which means potentially more tasks are excluded from the
// CumulativeLongQueuingDelay computation. So a more pessimistic FCP gives a more optimistic
// CumulativeLongQueuingDelay for the same work.
const fcpTimeInMs = extras.optimistic
? extras.fcpResult.pessimisticEstimate.timeInMs
: extras.fcpResult.optimisticEstimate.timeInMs;

// Optimistic Interactive Time means fewer tasks were considered while counting
// CumulativeLongQueuingDelay, which should result in a lower (better) value.
// Similarly, we always have pessimistic TTI >= optimistic TTI. Therefore, picking optimistic
// TTI means our window of interest is smaller and thus potentially more tasks are excluded from
// CumulativeLongQueuingDelay computation, yielding a lower (more optimistic)
// CumulativeLongQueuingDelay value for the same work.
const interactiveTimeMs = extras.optimistic
brendankenny marked this conversation as resolved.
Show resolved Hide resolved
? extras.interactiveResult.optimisticEstimate.timeInMs
: extras.interactiveResult.pessimisticEstimate.timeInMs;
Expand Down Expand Up @@ -101,7 +104,7 @@ class LanternCumulativeLongQueuingDelay extends LanternMetric {

for (const [node, timing] of nodeTimings.entries()) {
if (node.type !== BaseNode.TYPES.CPU) continue;
// Filtering out events below minimum duration to avoid unnecessary sorting work later.
// Filtering out events below minimum duration.
if (timing.duration < minDurationMs) continue;

events.push({
Expand All @@ -111,7 +114,7 @@ class LanternCumulativeLongQueuingDelay extends LanternMetric {
});
}

return events.sort((a, b) => a.start - b.start);
return events;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*/
'use strict';

const Audit = require('../../../audits/metrics/cumulative-long-queuing-delay.js');
const options = Audit.defaultOptions;
const cLQDAudit = require('../../../audits/metrics/cumulative-long-queuing-delay.js');
const options = cLQDAudit.defaultOptions;

const pwaTrace = require('../../fixtures/traces/progressive-app-m60.json');

function generateArtifactsWithTrace(trace) {
return {
traces: {[Audit.DEFAULT_PASS]: trace},
devtoolsLogs: {[Audit.DEFAULT_PASS]: []},
traces: {[cLQDAudit.DEFAULT_PASS]: trace},
devtoolsLogs: {[cLQDAudit.DEFAULT_PASS]: []},
};
}
/* eslint-env jest */
Expand All @@ -23,10 +23,10 @@ describe('Performance: cumulative-long-queuing-delay audit', () => {
const artifacts = generateArtifactsWithTrace(pwaTrace);
const settings = {throttlingMethod: 'provided'};
const context = {options, settings, computedCache: new Map()};
const output = await Audit.audit(artifacts, context);
const output = await cLQDAudit.audit(artifacts, context);

expect(output.numericValue).toBeCloseTo(48.3, 1);
expect(output.score).toBeCloseTo(1, 2);
expect(output.score).toBe(1);
expect(output.displayValue).toBeDisplayString('50\xa0ms');
});
});