Skip to content

Commit

Permalink
Update network throttling to simulate more realistic network conditio…
Browse files Browse the repository at this point in the history
…ns (#2238)
  • Loading branch information
wwwillchen authored and paulirish committed May 16, 2017
1 parent df2fae5 commit 2212ca2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lighthouse-core/audits/load-fast-enough-for-pwa.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class LoadFastEnough4Pwa extends Audit {
};
});

const latency3gMin = Emulation.settings.TYPICAL_MOBILE_THROTTLING_METRICS.latency - 10;
const latency3gMin = Emulation.settings.TYPICAL_MOBILE_THROTTLING_METRICS.targetLatency - 10;
const areLatenciesAll3G = allRequestLatencies.every(val =>
val === undefined || val.latency > latency3gMin);

Expand Down
21 changes: 18 additions & 3 deletions lighthouse-core/lib/emulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,25 @@ const NEXUS5X_USERAGENT = {
'(KHTML, like Gecko) Chrome/59.0.3033.0 Mobile Safari/537.36'
};

/**
* Adjustments needed for DevTools network throttling to simulate
* more realistic network conditions.
* See: crbug.com/721112
*/
const LATENCY_FACTOR = 3.75;
const THROUGHPUT_FACTOR = 0.9;

const TARGET_LATENCY = 150; // 150ms
const TARGET_DOWNLOAD_THROUGHPUT = Math.floor(1.6 * 1024 * 1024 / 8); // 1.6Mbps
const TARGET_UPLOAD_THROUGHPUT = Math.floor(750 * 1024 / 8); // 750Kbps

const TYPICAL_MOBILE_THROTTLING_METRICS = {
latency: 150, // 150ms
downloadThroughput: Math.floor(1.6 * 1024 * 1024 / 8), // 1.6Mbps
uploadThroughput: Math.floor(750 * 1024 / 8), // 750Kbps
targetLatency: TARGET_LATENCY,
latency: TARGET_LATENCY * LATENCY_FACTOR,
targetDownloadThroughput: TARGET_DOWNLOAD_THROUGHPUT,
downloadThroughput: TARGET_DOWNLOAD_THROUGHPUT * THROUGHPUT_FACTOR,
targetUploadThroughput: TARGET_UPLOAD_THROUGHPUT,
uploadThroughput: TARGET_UPLOAD_THROUGHPUT * THROUGHPUT_FACTOR,
offline: false
};

Expand Down

0 comments on commit 2212ca2

Please sign in to comment.