一、安装 SuperBenchmarker
1.安装 chocolatey
打开cmd,执行
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
按提示安装之后,就可以使用 chocolatey 进行 SuperBenchmarker 的安装了。
cinst SuperBenchmarker
二、使用 SuperBenchmarker
1.持续压测
-c 用于指定压测使用的线程数量,-n 用于指定请求总次数
sb -u "http://example.com" -c 1 -n 100
还有一个 -N 用于指定请求的持续时间,单位是秒
sb -u "http://example.com" -c 4 -N 1800
2.设置请求头进行压测
在当前目录下建 test.txt
vim test.txt
填入请求头
3.设置其他请求方式
sb 默认使用 GET 方式进行请求,如果需要其他请求方式,可以通过 -m 来指定。
下面我们使用 POST 请求,请求的 json 和请求头一样放在 test.txt 中,长这样。
Content-Type: application/json
{
"id": "1",
"name": "test",
"auth": "test"
}
sb -u "http://example.com" -c 10 -n 5000 -t test.txt -m POST
评论区