loadtest
对选定的 HTTP 或 WebSockets URL 进行负载测试。 API 允许你轻松集成到自己的测试中。
install
bash
npm install -g loadtestusage
| 参数 | 说明 |
|---|---|
-c | 并发数(concurrency) |
-n | 总请求数 |
--rps | 限制每秒请求数 |
-t | 持续时间(秒) |
-m | HTTP 方法(GET/POST/PUT/DELETE) |
-H "Header: value" | 自定义请求头 |
-P | POST body 数据 |
--timeout | 请求超时 |
bash
loadtest -n 100 -c 10 http://www.example.com/bash
loadtest -t 30 --rps 50 -c 10 http://localhost:3000/healthbash
loadtest -m POST -p data.json -T "application/json" -c 20 -n 500 http://localhost:3000/api/createbash
loadtest -H "Authorization: Bearer my-secret-token" -n 200 -c 5 http://localhost:3000/user/profilebash
loadtest ws://localhost:8080 -c 20 -n 200