Created
January 2, 2019 13:08
-
-
Save bloatfan/cc2f69f9e68230f0c51f7548c7beb4e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local threads = {} | |
wrk.headers['nonce'] = '1' | |
wrk.headers['sign'] = '1' | |
wrk.headers['token'] = '1' | |
wrk.headers['timestamp'] = '1' | |
setup = function (thread) | |
table.insert(threads, thread) | |
end | |
-- 初始化线程变量 | |
init = function (args) | |
results = {} | |
end | |
-- 这个在每个线程里面的执行的 | |
response = function (status, headers, body) | |
if (results[status] == nil) then | |
results[status] = 1 | |
else | |
results[status] = results[status] + 1 | |
end | |
end | |
-- 主线程做的事情 | |
done = function (summary, latency, requests) | |
local output = {} | |
for index, thread in ipairs(threads) do | |
local results = thread:get('results') | |
for status, count in pairs(results) do | |
if (output[status] == nil) then | |
output[status] = results[status] | |
else | |
output[status] = output[status] + results[status] | |
end | |
end | |
end | |
for status, count in pairs(output) do | |
print(status, ':', count) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment