侧边栏壁纸
  • 累计撰写 58 篇文章
  • 累计创建 67 个标签
  • 累计收到 1 条评论

可能是Windows下最好用的压测工具——SuperBenchmarker

lihaocheng
2021-10-21 / 0 评论 / 0 点赞 / 854 阅读 / 886 字
温馨提示:
晚上记得开启夜间模式哦

一、安装 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
0

评论区