Skip to content

Commit

Permalink
fix: allow overriding throttling and better defaults
Browse files Browse the repository at this point in the history
Closes #195
  • Loading branch information
harlan-zw committed Mar 4, 2024
1 parent 6aa27ff commit 933f297
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions packages/core/src/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,29 @@ export const resolveUserConfig: (userConfig: UserConfig) => Promise<ResolvedUser
else {
config.lighthouseOptions = {}
}
// for local urls we disable throttling
if (typeof config.scanner?.throttle) {
config.lighthouseOptions.throttlingMethod = 'provided'
config.lighthouseOptions.throttling = {
rttMs: 300,
throughputKbps: 700,
requestLatencyMs: 300 * 3.75,
downloadThroughputKbps: 700 * 3.75,
uploadThroughputKbps: 700 * 3.75,
cpuSlowdownMultiplier: 4, // cpu is already getting blasted
}
}
else if (!config.site || config.site.includes('localhost') || config.scanner?.throttle === false) {
config.lighthouseOptions.throttlingMethod = 'provided'
config.lighthouseOptions.throttling = {
rttMs: 0,
throughputKbps: 0,
cpuSlowdownMultiplier: 1,
requestLatencyMs: 0, // 0 means unset
downloadThroughputKbps: 0,
uploadThroughputKbps: 0,
if (typeof config.lighthouseOptions.throttlingMethod === 'undefined' && typeof config.lighthouseOptions.throttling === 'undefined') {
// for local urls we disable throttling
if (typeof config.scanner?.throttle) {
config.lighthouseOptions.throttlingMethod = 'simulate'
// we need a custom throttling profile to account for the cpu / network already getting blasted
config.lighthouseOptions.throttling = {
rttMs: 150,
throughputKbps: 1.6 * 1024,
requestLatencyMs: 150 * 4,
downloadThroughputKbps: 1.6 * 1024,
uploadThroughputKbps: 750,
cpuSlowdownMultiplier: 1,
}
} else if (!config.site || config.site.includes('localhost') || config.scanner?.throttle === false) {
config.lighthouseOptions.throttlingMethod = 'provided'
config.lighthouseOptions.throttling = {
rttMs: 0,
throughputKbps: 0,
cpuSlowdownMultiplier: 1,
requestLatencyMs: 0, // 0 means unset
downloadThroughputKbps: 0,
uploadThroughputKbps: 0,
}
}
}

Expand Down

0 comments on commit 933f297

Please sign in to comment.