我在 Windows 7 的 localhost 上运行 XAMPP。我试图找到一种方法来模拟拨号和 3G 连接的带宽。
当前是否有适用于 localhost 和 Windows 7 的解决方案,并且可以根据需要直接启用和禁用?
我在 Windows 7 的 localhost 上运行 XAMPP。我试图找到一种方法来模拟拨号和 3G 连接的带宽。
当前是否有适用于 localhost 和 Windows 7 的解决方案,并且可以根据需要直接启用和禁用?
使用 Chrome 开发者工具的最简单方法。在网络选项卡上,具有在不同用例中限制带宽的功能。
您可以使用@sitespeed.io/throttle - 一个 npm 包。
例子:
# simulate slow 3g connection on localhost
npx @sitespeed.io/throttle 3gslow --localhost
# throttle localhost with roundtrip time of 200ms
npx @sitespeed.io/throttle --rtt 200 --localhost
# later when you are done,... stop throttling
npx @sitespeed.io/throttle --stop --localhost
注意throttle
需要sudo,并且会提示用户登录。
或者,throttle
可以在 NodeJS 中以编程方式使用。示例(从文档复制):
const throttle = require('@sitespeed.io/throttle');
// Returns a promise
const options = {up: 360, down: 780, rtt: 200};
await throttle.start(options);
// Do your thing and then stop
await throttle.stop();
有关更多选项,请参阅文档。