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(lhr): include resourceSize in network-requests audit #7056

Merged
merged 1 commit into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions lighthouse-core/audits/network-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class NetworkRequests extends Audit {
startTime: timeToMs(record.startTime),
endTime: timeToMs(record.endTime),
transferSize: record.transferSize,
resourceSize: record.resourceSize,
statusCode: record.statusCode,
mimeType: record.mimeType,
resourceType: record.resourceType,
Expand All @@ -63,6 +64,13 @@ class NetworkRequests extends Audit {
granularity: 1,
text: 'Transfer Size',
},
{
key: 'resourceSize',
itemType: 'bytes',
displayUnit: 'kb',
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't this bytes?

image

Copy link
Collaborator

@patrickhulce patrickhulce Jan 18, 2019

Choose a reason for hiding this comment

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

yeah it is, i18n lib converts it I believe

// Replace all the bytes with KB
parsed.elements
.filter(el => el.format && el.format.style === 'bytes')
// @ts-ignore - el.id is always defined when el.format is defined
.forEach(el => (clonedValues[el.id] = clonedValues[el.id] / 1024));

Copy link
Member

Choose a reason for hiding this comment

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

yeah, it's interpreted by the itemType but is put into the LHR as the displayUnit

Copy link
Member

Choose a reason for hiding this comment

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

but is put into the LHR as the displayUnit

er, that's not right. It is if it's in an i18ned string, otherwise it's not until details-renderer.js that the displayUnit is used...which is pointless here because these aren't displayed in the html report

granularity: 1,
text: 'Resource Size',
},
{key: 'statusCode', itemType: 'text', text: 'Status Code'},
{key: 'mimeType', itemType: 'text', text: 'MIME Type'},
{key: 'resourceType', itemType: 'text', text: 'Resource Type'},
Expand Down
25 changes: 25 additions & 0 deletions lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,13 @@
"granularity": 1,
"text": "Transfer Size"
},
{
"key": "resourceSize",
"itemType": "bytes",
"displayUnit": "kb",
"granularity": 1,
"text": "Resource Size"
},
{
"key": "statusCode",
"itemType": "text",
Expand All @@ -843,6 +850,7 @@
"startTime": 0,
"endTime": 640.1550000009593,
"transferSize": 12640,
"resourceSize": 12519,
"statusCode": 200,
"mimeType": "text/html",
"resourceType": "Document"
Expand All @@ -852,6 +860,7 @@
"startTime": 630.2950000099372,
"endTime": 2635.035000013886,
"transferSize": 821,
"resourceSize": 677,
"statusCode": 200,
"mimeType": "text/css",
"resourceType": "Stylesheet"
Expand All @@ -861,6 +870,7 @@
"startTime": 635.496000002604,
"endTime": 1204.6590000099968,
"transferSize": 821,
"resourceSize": 677,
"statusCode": 200,
"mimeType": "text/css",
"resourceType": "Stylesheet"
Expand All @@ -870,6 +880,7 @@
"startTime": 636.6400000115391,
"endTime": 1213.2910000218544,
"transferSize": 139,
"resourceSize": 0,
Copy link
Member

Choose a reason for hiding this comment

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

why do these 0 resourceSize items have transferSize set?

Copy link
Member

Choose a reason for hiding this comment

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

why do these 0 resourceSize items have transferSize set?

and this makes a lot more sense now when 139 isn't the transferSize in KB, it's in bytes :)

"statusCode": 404,
"mimeType": "text/css",
"resourceType": "Stylesheet"
Expand All @@ -879,6 +890,7 @@
"startTime": 638.0040000076406,
"endTime": 2849.3670000170823,
"transferSize": 821,
"resourceSize": 677,
"statusCode": 200,
"mimeType": "text/css",
"resourceType": "Stylesheet"
Expand All @@ -888,6 +900,7 @@
"startTime": 638.7899999972433,
"endTime": 1220.04100002232,
"transferSize": 1108,
"resourceSize": 964,
"statusCode": 200,
"mimeType": "text/css",
"resourceType": "Stylesheet"
Expand All @@ -897,6 +910,7 @@
"startTime": 640.5979999981355,
"endTime": 1228.5180000180844,
"transferSize": 736,
"resourceSize": 616,
"statusCode": 200,
"mimeType": "text/html",
"resourceType": "Document"
Expand All @@ -906,6 +920,7 @@
"startTime": 641.3450000109151,
"endTime": 1776.4320000133011,
"transferSize": 733,
"resourceSize": 613,
"statusCode": 200,
"mimeType": "text/html",
"resourceType": "Document"
Expand All @@ -915,6 +930,7 @@
"startTime": 642.8679999953602,
"endTime": 4216.161000018474,
"transferSize": 821,
"resourceSize": 677,
"statusCode": 200,
"mimeType": "text/css",
"resourceType": "Stylesheet"
Expand All @@ -924,6 +940,7 @@
"startTime": 644.0820000134408,
"endTime": 1792.0860000012908,
"transferSize": 1703,
"resourceSize": 1552,
"statusCode": 200,
"mimeType": "text/javascript",
"resourceType": "Script"
Expand All @@ -933,6 +950,7 @@
"startTime": 645.529000001261,
"endTime": 1236.1859999946319,
"transferSize": 144,
"resourceSize": 0,
"statusCode": 200,
"mimeType": "text/javascript",
"resourceType": "Script"
Expand All @@ -942,6 +960,7 @@
"startTime": 3951.6250000160653,
"endTime": 4779.641000000993,
"transferSize": 24741,
"resourceSize": 24620,
"statusCode": 200,
"mimeType": "image/jpeg",
"resourceType": "Image"
Expand All @@ -951,6 +970,7 @@
"startTime": 2849.7340000176337,
"endTime": 3961.049000005005,
"transferSize": 71654,
"resourceSize": 71501,
"statusCode": 200,
"mimeType": "text/javascript",
"resourceType": "Script"
Expand All @@ -960,6 +980,7 @@
"startTime": 3874.7540000185836,
"endTime": 4796.288000012282,
"transferSize": 30174,
"resourceSize": 84245,
"statusCode": 200,
"mimeType": "text/javascript",
"resourceType": "Script"
Expand All @@ -969,6 +990,7 @@
"startTime": 2924.34100000537,
"endTime": 3964.233000006061,
"transferSize": 821,
"resourceSize": 677,
"statusCode": 200,
"mimeType": "text/css",
"resourceType": "Stylesheet"
Expand All @@ -978,6 +1000,7 @@
"startTime": 3066.252999997232,
"endTime": 3772.7560000203084,
"transferSize": 12640,
"resourceSize": 12519,
"statusCode": 200,
"mimeType": "text/html",
"resourceType": "XHR"
Expand All @@ -987,6 +1010,7 @@
"startTime": 3829.6360000094865,
"endTime": 3968.59800000675,
"transferSize": 0,
"resourceSize": 4,
"statusCode": 200,
"mimeType": "text/plain",
"resourceType": "Image"
Expand All @@ -996,6 +1020,7 @@
"startTime": 4967.373000021325,
"endTime": 5536.498000001302,
"transferSize": 221,
"resourceSize": 95,
"statusCode": 404,
"mimeType": "text/plain",
"resourceType": "Other"
Expand Down
25 changes: 25 additions & 0 deletions proto/sample_v2_round_trip.json
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,13 @@
"key": "transferSize",
"text": "Transfer Size"
},
{
"displayUnit": "kb",
"granularity": 1.0,
"itemType": "bytes",
"key": "resourceSize",
"text": "Resource Size"
},
{
"itemType": "text",
"key": "statusCode",
Expand All @@ -1379,6 +1386,7 @@
{
"endTime": 640.1550000009593,
"mimeType": "text/html",
"resourceSize": 12519.0,
"resourceType": "Document",
"startTime": 0.0,
"statusCode": 200.0,
Expand All @@ -1388,6 +1396,7 @@
{
"endTime": 2635.035000013886,
"mimeType": "text/css",
"resourceSize": 677.0,
"resourceType": "Stylesheet",
"startTime": 630.2950000099372,
"statusCode": 200.0,
Expand All @@ -1397,6 +1406,7 @@
{
"endTime": 1204.6590000099968,
"mimeType": "text/css",
"resourceSize": 677.0,
"resourceType": "Stylesheet",
"startTime": 635.496000002604,
"statusCode": 200.0,
Expand All @@ -1406,6 +1416,7 @@
{
"endTime": 1213.2910000218544,
"mimeType": "text/css",
"resourceSize": 0.0,
"resourceType": "Stylesheet",
"startTime": 636.6400000115391,
"statusCode": 404.0,
Expand All @@ -1415,6 +1426,7 @@
{
"endTime": 2849.3670000170823,
"mimeType": "text/css",
"resourceSize": 677.0,
"resourceType": "Stylesheet",
"startTime": 638.0040000076406,
"statusCode": 200.0,
Expand All @@ -1424,6 +1436,7 @@
{
"endTime": 1220.04100002232,
"mimeType": "text/css",
"resourceSize": 964.0,
"resourceType": "Stylesheet",
"startTime": 638.7899999972433,
"statusCode": 200.0,
Expand All @@ -1433,6 +1446,7 @@
{
"endTime": 1228.5180000180844,
"mimeType": "text/html",
"resourceSize": 616.0,
"resourceType": "Document",
"startTime": 640.5979999981355,
"statusCode": 200.0,
Expand All @@ -1442,6 +1456,7 @@
{
"endTime": 1776.4320000133011,
"mimeType": "text/html",
"resourceSize": 613.0,
"resourceType": "Document",
"startTime": 641.3450000109151,
"statusCode": 200.0,
Expand All @@ -1451,6 +1466,7 @@
{
"endTime": 4216.161000018474,
"mimeType": "text/css",
"resourceSize": 677.0,
"resourceType": "Stylesheet",
"startTime": 642.8679999953602,
"statusCode": 200.0,
Expand All @@ -1460,6 +1476,7 @@
{
"endTime": 1792.0860000012908,
"mimeType": "text/javascript",
"resourceSize": 1552.0,
"resourceType": "Script",
"startTime": 644.0820000134408,
"statusCode": 200.0,
Expand All @@ -1469,6 +1486,7 @@
{
"endTime": 1236.1859999946319,
"mimeType": "text/javascript",
"resourceSize": 0.0,
"resourceType": "Script",
"startTime": 645.529000001261,
"statusCode": 200.0,
Expand All @@ -1478,6 +1496,7 @@
{
"endTime": 4779.641000000993,
"mimeType": "image/jpeg",
"resourceSize": 24620.0,
"resourceType": "Image",
"startTime": 3951.6250000160653,
"statusCode": 200.0,
Expand All @@ -1487,6 +1506,7 @@
{
"endTime": 3961.049000005005,
"mimeType": "text/javascript",
"resourceSize": 71501.0,
"resourceType": "Script",
"startTime": 2849.7340000176337,
"statusCode": 200.0,
Expand All @@ -1496,6 +1516,7 @@
{
"endTime": 4796.288000012282,
"mimeType": "text/javascript",
"resourceSize": 84245.0,
"resourceType": "Script",
"startTime": 3874.7540000185836,
"statusCode": 200.0,
Expand All @@ -1505,6 +1526,7 @@
{
"endTime": 3964.233000006061,
"mimeType": "text/css",
"resourceSize": 677.0,
"resourceType": "Stylesheet",
"startTime": 2924.34100000537,
"statusCode": 200.0,
Expand All @@ -1514,6 +1536,7 @@
{
"endTime": 3772.7560000203084,
"mimeType": "text/html",
"resourceSize": 12519.0,
"resourceType": "XHR",
"startTime": 3066.252999997232,
"statusCode": 200.0,
Expand All @@ -1523,6 +1546,7 @@
{
"endTime": 3968.59800000675,
"mimeType": "text/plain",
"resourceSize": 4.0,
"resourceType": "Image",
"startTime": 3829.6360000094865,
"statusCode": 200.0,
Expand All @@ -1532,6 +1556,7 @@
{
"endTime": 5536.498000001302,
"mimeType": "text/plain",
"resourceSize": 95.0,
"resourceType": "Other",
"startTime": 4967.373000021325,
"statusCode": 404.0,
Expand Down