Skip to content

Commit

Permalink
track number of completed requests in total-byte-weight extendedInfo (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny authored Jul 17, 2017
1 parent 5d61056 commit eecf525
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lighthouse-core/audits/byte-efficiency/total-byte-weight.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class TotalByteWeight extends ByteEfficiencyAudit {
totalBytes += result.totalBytes;
results.push(result);
});
const totalCompletedRequests = results.length;
results = results.sort((itemA, itemB) => itemB.totalBytes - itemA.totalBytes).slice(0, 10);


Expand Down Expand Up @@ -91,6 +92,7 @@ class TotalByteWeight extends ByteEfficiencyAudit {
extendedInfo: {
value: {
results,
totalCompletedRequests
}
},
details: tableDetails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('Total byte weight audit', () => {
assert.strictEqual(result.score, 100);
const results = result.details.items;
assert.strictEqual(results.length, 3);
assert.strictEqual(result.extendedInfo.value.totalCompletedRequests, 3);
assert.strictEqual(results[0][1].text, `70${NBSP}KB`, 'results are sorted');
});
});
Expand All @@ -69,6 +70,7 @@ describe('Total byte weight audit', () => {
assert.strictEqual(result.rawValue, 4180 * 1024);
const results = result.details.items;
assert.strictEqual(results.length, 10, 'results are clipped at top 10');
assert.strictEqual(result.extendedInfo.value.totalCompletedRequests, 11);
});
});

Expand Down

0 comments on commit eecf525

Please sign in to comment.