Skip to content

Commit

Permalink
Merge 75c28f1 into c3db893
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Nov 17, 2020
2 parents c3db893 + 75c28f1 commit 175f130
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ module.exports = class ConnectionPool {
throw new Error(`Could not find a connection for origin: ${origin}`);
}

// Make sure each origin has minimum number of connections available for max throughput
while (connections.length < CONNECTIONS_PER_ORIGIN) connections.push(connections[0].clone());
// Make sure each origin has minimum number of connections available for max throughput.
// But only if it's not over H2 which maximizes throughput already.
const minConnections = connections[0].isH2() ? 1 : CONNECTIONS_PER_ORIGIN;
while (connections.length < minConnections) connections.push(connections[0].clone());

this._connectionsByOrigin.set(origin, connections);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Object {
exports[`Performance: metrics evaluates valid input correctly 1`] = `
Object {
"cumulativeLayoutShift": 0,
"estimatedInputLatency": 78,
"estimatedInputLatency": 81,
"estimatedInputLatencyTs": undefined,
"firstCPUIdle": 3351,
"firstCPUIdleTs": undefined,
Expand Down Expand Up @@ -137,6 +137,6 @@ Object {
"observedTraceEndTs": 225426711887,
"speedIndex": 1676,
"speedIndexTs": undefined,
"totalBlockingTime": 726,
"totalBlockingTime": 777,
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ describe('Render blocking resources audit', () => {
'url': 'https://fonts.googleapis.com/css?family=Fira+Sans+Condensed%3A400%2C400i%2C600%2C600i&subset=latin%2Clatin-ext&display=swap',
'wastedMs': 440,
},
{
'totalBytes': 621,
'url': 'https://fonts.googleapis.com/css?family=Montserrat',
'wastedMs': 440,
},
// Due to internal H2 simulation details, parallel HTTP/2 requests are pipelined which makes
// it look like Montserrat starts after Fira Sans finishes. It would be preferred
// if eventual simulation improvements list Montserrat here as well.
]);
});

Expand Down
8 changes: 4 additions & 4 deletions lighthouse-core/test/audits/dobetterweb/uses-http2-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ describe('Resources are fetched over http/2', () => {
// make sure we flag all the rest
expect(result.details.items).toHaveLength(60);
// make sure we report savings
expect(result.numericValue).toMatchInlineSnapshot(`1030`);
expect(result.details.overallSavingsMs).toMatchInlineSnapshot(`1030`);
expect(result.numericValue).toMatchInlineSnapshot(`1310`);
expect(result.details.overallSavingsMs).toMatchInlineSnapshot(`1310`);
// make sure we have a failing score
expect(result.score).toBeLessThan(0.5);
});
Expand All @@ -70,7 +70,7 @@ describe('Resources are fetched over http/2', () => {
expect(urls).not.toContain(records[30].url);
expect(result.details.items).toHaveLength(30);
// make sure we report less savings
expect(result.numericValue).toMatchInlineSnapshot(`250`);
expect(result.details.overallSavingsMs).toMatchInlineSnapshot(`250`);
expect(result.numericValue).toMatchInlineSnapshot(`850`);
expect(result.details.overallSavingsMs).toMatchInlineSnapshot(`850`);
});
});
8 changes: 4 additions & 4 deletions lighthouse-core/test/audits/timing-budget-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Performance: Timing budget audit', () => {
context = {
computedCache: new Map(),
settings: {
throttlingMethod: 'simulate',
throttlingMethod: 'devtools',
},
};
});
Expand Down Expand Up @@ -63,15 +63,15 @@ describe('Performance: Timing budget audit', () => {
const items = result.details.items;
// Failing Budget
expect(items[0].label).toBeDisplayString('Estimated Input Latency');
expect(items[0].measurement).toBeCloseTo(77.8);
expect(items[0].overBudget).toBeCloseTo(67.8);
expect(items[0].measurement).toBeCloseTo(17.07);
expect(items[0].overBudget).toBeCloseTo(7.07);
});

it('calculates the "overBudget" column correctly', async () => {
const result = await TimingBudgetAudit.audit(artifacts, context);

// Failing Budget
expect(result.details.items[0].overBudget).toBeCloseTo(67.8);
expect(result.details.items[0].overBudget).toBeCloseTo(7.07);

// Passing Budget
expect(result.details.items[1].overBudget).toBeUndefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

exports[`Metrics: EIL should compute a simulated value 1`] = `
Object {
"optimistic": 93,
"optimistic": 101,
"pessimistic": 101,
"timing": 78,
"timing": 81,
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

exports[`Metrics: Lantern EIL should compute a simulated value 1`] = `
Object {
"optimistic": 93,
"optimistic": 101,
"pessimistic": 101,
"timing": 78,
"timing": 81,
}
`;
4 changes: 2 additions & 2 deletions lighthouse-core/test/computed/metrics/timing-summary-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Timing summary', () => {
expect(result.metrics).toMatchInlineSnapshot(`
Object {
"cumulativeLayoutShift": 0,
"estimatedInputLatency": 77.79999999999995,
"estimatedInputLatency": 80.93333333333328,
"estimatedInputLatencyTs": undefined,
"firstCPUIdle": 3351.3320000492963,
"firstCPUIdleTs": undefined,
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('Timing summary', () => {
"observedTraceEndTs": 225426711887,
"speedIndex": 1676.1335047609864,
"speedIndexTs": undefined,
"totalBlockingTime": 726.4774999940994,
"totalBlockingTime": 776.9999999999995,
}
`);
// Includes performance metrics
Expand Down
84 changes: 48 additions & 36 deletions lighthouse-core/test/computed/metrics/total-blocking-time-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ describe('Metrics: TotalBlockingTime', () => {
optimistic: Math.round(result.optimisticEstimate.timeInMs),
pessimistic: Math.round(result.pessimisticEstimate.timeInMs),
}).toMatchInlineSnapshot(`
Object {
"optimistic": 676,
"pessimistic": 777,
"timing": 726,
}
`);
Object {
"optimistic": 777,
"pessimistic": 777,
"timing": 777,
}
`);
});

it('should compute an observed value', async () => {
Expand Down Expand Up @@ -94,42 +94,54 @@ Object {
const fcpTimeMs = 1000;
const interactiveTimeMs = 2000;

expect(TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 1951, end: 2100, duration: 149}],
fcpTimeMs,
interactiveTimeMs
)).toBe(0); // Duration after clipping is 49, which is < 50.
expect(TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 1950, end: 2100, duration: 150}],
fcpTimeMs,
interactiveTimeMs
)).toBe(0); // Duration after clipping is 50, so time after 50ms is 0ms.
expect(TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 1949, end: 2100, duration: 151}],
fcpTimeMs,
interactiveTimeMs
)).toBe(1); // Duration after clipping is 51, so time after 50ms is 1ms.
expect(
TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 1951, end: 2100, duration: 149}],
fcpTimeMs,
interactiveTimeMs
)
).toBe(0); // Duration after clipping is 49, which is < 50.
expect(
TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 1950, end: 2100, duration: 150}],
fcpTimeMs,
interactiveTimeMs
)
).toBe(0); // Duration after clipping is 50, so time after 50ms is 0ms.
expect(
TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 1949, end: 2100, duration: 151}],
fcpTimeMs,
interactiveTimeMs
)
).toBe(1); // Duration after clipping is 51, so time after 50ms is 1ms.
});

it('clips properly if FCP falls in the middle of a task', () => {
const fcpTimeMs = 1000;
const interactiveTimeMs = 2000;

expect(TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 900, end: 1049, duration: 149}],
fcpTimeMs,
interactiveTimeMs
)).toBe(0); // Duration after clipping is 49, which is < 50.
expect(TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 900, end: 1050, duration: 150}],
fcpTimeMs,
interactiveTimeMs
)).toBe(0); // Duration after clipping is 50, so time after 50ms is 0ms.
expect(TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 900, end: 1051, duration: 151}],
fcpTimeMs,
interactiveTimeMs
)).toBe(1); // Duration after clipping is 51, so time after 50ms is 1ms.
expect(
TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 900, end: 1049, duration: 149}],
fcpTimeMs,
interactiveTimeMs
)
).toBe(0); // Duration after clipping is 49, which is < 50.
expect(
TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 900, end: 1050, duration: 150}],
fcpTimeMs,
interactiveTimeMs
)
).toBe(0); // Duration after clipping is 50, so time after 50ms is 0ms.
expect(
TotalBlockingTime.calculateSumOfBlockingTime(
[{start: 900, end: 1051, duration: 151}],
fcpTimeMs,
interactiveTimeMs
)
).toBe(1); // Duration after clipping is 51, so time after 50ms is 1ms.
});

// This can happen in the lantern metric case, where we use the optimistic
Expand Down
14 changes: 7 additions & 7 deletions lighthouse-core/test/fixtures/lantern-master-accuracy.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"roughEstimateOfFCP": {
"p50": 0.292391744233104,
"p90": 0.5016256386437529,
"p90": 0.501397081651661,
"p95": 0.5795269168026101
},
"roughEstimateOfFMP": {
"p50": 0.301651376146789,
"p50": 0.30206175397060275,
"p90": 0.5385564466378778,
"p95": 0.6641924269472893
},
Expand All @@ -15,17 +15,17 @@
"p95": 1.0080896079651525
},
"roughEstimateOfTTFCPUI": {
"p50": 0.3019386772996013,
"p90": 0.6660228191537149,
"p95": 0.9489925320557983
"p50": 0.28465238303454304,
"p90": 0.6509379230322955,
"p95": 0.8098063599218334
},
"roughEstimateOfTTI": {
"p50": 0.2841942294159043,
"p50": 0.3055258632709021,
"p90": 0.6577081000373274,
"p95": 0.743897672766033
},
"roughEstimateOfLCP": {
"p50": 0.21026850507982583,
"p50": 0.203757225433526,
"p90": 0.6464365256124721,
"p95": 0.8768898488120951
}
Expand Down
Loading

0 comments on commit 175f130

Please sign in to comment.