Open GenweiWu opened 3 years ago
git clone https://github.com/wg/wrk.git cd wrk make #编译后得到wrk执行文件
## 通过下面的方式,找出可用的path路径,然后将wrk放到任一路径下即可使用 ## which wrk /usr/bin/which: no wrk in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
cat test.lua wrk.method="GET" wrk.path = "/test-service/menu/refresh"
cat test.lua
wrk.method="GET" wrk.path = "/test-service/menu/refresh"
function request()
local requestPath=wrk.path local resp = wrk.format(nil,requestPath) return resp end
response = function(status, headers, body) print("status is:",status) if status ~= 200 then print("body = ",body) -- token = headers["X-Token"] --path = "/resource" --wrk.headers["X-Token"] = token end end
```bash wrk -t1 -c1 -d1s -s test.lua --latency https://abc.com ## t12表示12个线程,c200表示200个连接,d30s表示测试时间为30s wrk -t12 -c200 -d30s -s test.lua --latency https://abc.com
安装
lua构造请求
function request()
local requestPath=wrk.path local resp = wrk.format(nil,requestPath) return resp end
response = function(status, headers, body) print("status is:",status) if status ~= 200 then print("body = ",body) -- token = headers["X-Token"] --path = "/resource" --wrk.headers["X-Token"] = token end end
参考