Created
January 30, 2018 15:06
-
-
Save bloatfan/049c9cd269697ab1721bdf84f32e36ab 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 = {} | |
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