我需要对将参数作为输入的 REST API 进行基准测试。我想知道是否有办法使用 wrk
来做到这一点.现在我没有看到这样的选项:
user@Ubuntu-K56CA:~/wrk$ ./wrk
Usage: wrk <options> <url>
Options:
-c, --connections <N> Connections to keep open
-d, --duration <T> Duration of test
-t, --threads <N> Number of threads to use
-s, --script <S> Load Lua script file
-H, --header <H> Add header to request
--latency Print latency statistics
--timeout <T> Socket/request timeout
-v, --version Print version details
当我查看此文件时:https://github.com/wg/wrk/blob/master/src/wrk.lua
我没看到
params
随处使用。也在搜索 params
在 wrk
repo 没有产生任何有用的东西。我错过了什么吗?
最佳答案
您可以将其添加到 url 中:
./wrk -c1 -t1 -d5s http://server.com/my_path?param_name=param_value
或者如果您想在测试期间生成它,您可以使用脚本来完成:
./wrk -t1 -c1 -d5s -s ./scripts/my_script.lua http://server.com
哪里
my_script.lua
是:request = function()
wrk.headers["Connection"] = "Keep-Alive"
param_value = math.random(1,100)
path = "/my_path?param_name=" .. param_value
return wrk.format("GET", path)
end
关于rest - 有没有办法使用 wrk 将参数传递给 GET 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33548940/