Files
tldr/pages.zh/common/k6.md

36 lines
940 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# k6
> 开源负载测试工具和SaaS适用于工程团队。
> 更多信息:<https://k6.io>。
- 在本地运行负载测试:
`k6 run {{script.js}}`
- 在本地以指定数量的虚拟用户和持续时间运行负载测试:
`k6 run --vus {{10}} --duration {{30s}} {{script.js}}`
- 在本地以指定的环境变量运行负载测试:
`k6 run -e {{HOSTNAME=example.com}} {{script.js}}`
- 在本地使用InfluxDB存储结果运行负载测试
`k6 run --out influxdb={{http://localhost:8086/k6db}} {{script.js}}`
- 在本地运行负载测试并丢弃响应体(显著更快):
`k6 run --discard-response-bodies {{script.js}}`
- 在本地使用基础JavaScript兼容模式运行负载测试显著更快
`k6 run --compatibility-mode=base {{script.js}}`
- 使用秘密令牌登录云服务:
`k6 login cloud --token {{secret}}`
- 在云基础设施上运行负载测试:
`k6 cloud {{script.js}}`