Created
October 30, 2017 22:08
-
-
Save tejaskokje/2e5c44b5039078f236665aa1c32b9b2e to your computer and use it in GitHub Desktop.
json.lua for wrk2
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
-- example reporting script which demonstrates a custom | |
-- done() function that prints results as JSON | |
done = function(summary, latency, requests) | |
io.write("\nJSON Output:\n") | |
io.write("{\n") | |
io.write(string.format("\t\"requests\": %d,\n", summary.requests)) | |
io.write(string.format("\t\"duration_in_microseconds\": %0.2f,\n", summary.duration)) | |
io.write(string.format("\t\"bytes\": %d,\n", summary.bytes)) | |
io.write(string.format("\t\"requests_per_sec\": %0.2f,\n", (summary.requests/summary.duration)*1e6)) | |
io.write(string.format("\t\"bytes_transfer_per_sec\": %0.2f,\n", (summary.bytes/summary.duration)*1e6)) | |
io.write("\t\"latency_distribution\": [\n") | |
for _, p in pairs({ 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 99, 99.9, 99.99, 99.999, 100 }) do | |
io.write("\t\t{\n") | |
n = latency:percentile(p) | |
io.write(string.format("\t\t\t\"percentile\": %g,\n\t\t\t\"latency_in_microseconds\": %d\n", p, n)) | |
if p == 100 then | |
io.write("\t\t}\n") | |
else | |
io.write("\t\t},\n") | |
end | |
end | |
io.write("\t]\n}\n") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment