Skip to content

loadtest

对选定的 HTTP 或 WebSockets URL 进行负载测试。 API 允许你轻松集成到自己的测试中。

install

bash
npm install -g loadtest

usage

参数说明
-c并发数(concurrency)
-n总请求数
--rps限制每秒请求数
-t持续时间(秒)
-mHTTP 方法(GET/POST/PUT/DELETE)
-H "Header: value"自定义请求头
-PPOST body 数据
--timeout请求超时
bash
loadtest -n 100 -c 10 http://www.example.com/
bash
loadtest -t 30 --rps 50 -c 10 http://localhost:3000/health
bash
loadtest -m POST -p data.json -T "application/json" -c 20 -n 500 http://localhost:3000/api/create
bash
loadtest -H "Authorization: Bearer my-secret-token" -n 200 -c 5 http://localhost:3000/user/profile
bash
loadtest ws://localhost:8080 -c 20 -n 200

Released under the MIT License.