Skip to content

Commit

Permalink
Merge pull request #645 from HTTPArchive/lightrider
Browse files Browse the repository at this point in the history
Use a fast 4G profile when running desktop lighthouse tests
  • Loading branch information
mjkozicki committed Apr 17, 2024
2 parents 4536ff0 + f904e55 commit 0521863
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
7 changes: 6 additions & 1 deletion internal/devtools_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,12 @@ def run_lighthouse_test(self, task):
else:
cpu_throttle = '{:.3f}'.format(self.job['throttle_cpu']) if 'throttle_cpu' in self.job else '1'
if self.job['dtShaper']:
command.extend(['--throttling-method', 'devtools', '--throttling.requestLatencyMs', '150', '--throttling.downloadThroughputKbps', '1600', '--throttling.uploadThroughputKbps', '768', '--throttling.cpuSlowdownMultiplier', cpu_throttle])
if self.options.android or ('mobile' in self.job and self.job['mobile']):
# 1.6Mbps down, 750Kbps up, 150ms RTT
command.extend(['--throttling-method', 'devtools', '--throttling.requestLatencyMs', '150', '--throttling.downloadThroughputKbps', '1600', '--throttling.uploadThroughputKbps', '750', '--throttling.cpuSlowdownMultiplier', cpu_throttle])
else:
# 10Mbps, 40ms RTT
command.extend(['--throttling-method', 'devtools', '--throttling.requestLatencyMs', '40', '--throttling.downloadThroughputKbps', '10240', '--throttling.uploadThroughputKbps', '10240', '--throttling.cpuSlowdownMultiplier', cpu_throttle])
elif 'throttle_cpu_requested' in self.job and self.job['throttle_cpu_requested'] > 1:
command.extend(['--throttling-method', 'devtools', '--throttling.requestLatencyMs', '0', '--throttling.downloadThroughputKbps', '0', '--throttling.uploadThroughputKbps', '0', '--throttling.cpuSlowdownMultiplier', cpu_throttle])
else:
Expand Down
18 changes: 13 additions & 5 deletions internal/traffic_shaping.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, options, root_path):
shaper_name = options.shaper
self.support_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "support")
self.shaper = None
self.options = options
plat = platform.system()
if shaper_name is None and plat == "Linux":
shaper_name = 'netem'
Expand Down Expand Up @@ -98,13 +99,20 @@ def configure(self, job, task):
if 'shaperLimit' in job:
shaperLimit = self._to_int(job['shaperLimit'])
if self.shaper is not None:
# If a lighthouse test is running, force the Lighthouse 3G profile:
# If a lighthouse test is running, force the Lighthouse 3G profile for mobile
# or 4G for desktop:
# https://github.com/GoogleChrome/lighthouse/blob/master/docs/throttling.md
# 1.6Mbps down, 750Kbps up, 150ms RTT
if task['running_lighthouse'] and not job['lighthouse_throttle']:
rtt = 150
in_bps = 1600000
out_bps = 750000
if self.options.android or ('mobile' in job and job['mobile']):
# 1.6Mbps down, 750Kbps up, 150ms RTT
rtt = 150
in_bps = 1600000
out_bps = 750000
else:
# 10Mbps, 40ms RTT
rtt = 40
in_bps = 10240000
out_bps = 10240000
plr = .0
shaperLimit = 0
logging.debug('Configuring traffic shaping: %d/%d - %d ms, %0.2f%% plr, %d tc-qdisc limit',
Expand Down

0 comments on commit 0521863

Please sign in to comment.