Skip to content

Commit

Permalink
track number of completed requests in total-byte-weight
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Jul 17, 2017
1 parent fedc76a commit 64acf9d
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
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
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 64acf9d

Please sign in to comment.