有没有办法使用 wrk 将参数传递给 GET 请求?
Is there a way to pass parameters to GET request using wrk?
我需要对将参数作为输入的 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
在任何地方使用过。在 wrk
回购中寻找 params
也没有产生任何有用的东西。
我是不是漏掉了什么?
您可以直接在 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 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
在任何地方使用过。在 wrk
回购中寻找 params
也没有产生任何有用的东西。
我是不是漏掉了什么?
您可以直接在 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