-- example script that demonstrates use of setup() to pass-- data to and from the threadslocal counter = 1local threads = {}function setup(thread)thread:set("id", counter)table.insert(threads, thread)counter = counter + 1endfunction init(args)requests = 0responses = 0local msg = "thread %d created"print(msg:format(id))endfunction request()requests = requests + 1return wrk.request()endfunction response(status, headers, body)responses = responses + 1endfunction done(summary, latency, requests)for index, thread in ipairs(threads) dolocal id = thread:get("id")local requests = thread:get("requests")local responses = thread:get("responses")local msg = "thread %d made %d requests and got %d responses"print(msg:format(id, requests, responses))endend
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。