Wrk脚本

本例主要用来演示如何使用 wrk script 来进行压测

这里使用的还是我们的 whoami

下面这个脚本可以将返回的 response 写入到文件里

-- example script that demonstrates response handling and
-- retrieving an authentication token to set on all future
-- requests

-- wrk -c 1 -t 1 -d 5 -s ./test.lua http://whoami.lizhe.com

token = nil
path  = "/"
logfile = io.open("wrk.log", "w");

request = function()
    wrk.headers["test_token"] = "helloworld"
    return wrk.format("GET", path)
end

response = function(status, headers, body)
    logfile:write("status:" .. status .. "\n");
    logfile:write("body:" .. body .. "\n");
end

ulimit -n 2048

Send a Message