Skip to content

Instantly share code, notes, and snippets.

@bloatfan
Created January 2, 2019 13:08
Show Gist options
  • Save bloatfan/cc2f69f9e68230f0c51f7548c7beb4e9 to your computer and use it in GitHub Desktop.
Save bloatfan/cc2f69f9e68230f0c51f7548c7beb4e9 to your computer and use it in GitHub Desktop.
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