Skip to content

Instantly share code, notes, and snippets.

@maurorappa
Created January 23, 2026 17:27
Show Gist options
  • Select an option

  • Save maurorappa/dad88ca86dffba806b580d790bf90947 to your computer and use it in GitHub Desktop.

Select an option

Save maurorappa/dad88ca86dffba806b580d790bf90947 to your computer and use it in GitHub Desktop.
wrk(http benchmark took) lua report script
done = function(summary, latency, requests)
local bucket_size = 1000
local star_value = 100
io.write("\n--------------------- percentiles ----------------\n")
for _, p in pairs({ 50, 75, 90, 99, 99.999 }) do
n = latency:percentile(p)
io.write(string.format("%gp, %d\n", p, n))
end
io.write("------------ bucket distribution ------------------\n")
local counts = {}
for i=1, #latency do
local group = math.floor(latency(i) / bucket_size) * bucket_size
counts[group] = (counts[group] or 0) + 1
end
local groups = {}
for g in pairs(counts) do
table.insert(groups, g)
end
table.sort(groups)
for _, g in ipairs(groups) do
tot = math.floor(counts[g]/star_value)
if tot > 0 then
io.write(string.format("%2dus: %s\n", g, string.rep("*", tot)))
end
end
io.write("------------ 1 * = "..star_value.." measurements ----------------\n\n")
end
@maurorappa
Copy link
Author

better reporting for wrk (https://github.com/wg/wrk)

It provides percentiles and bucket distribution to quickly evaluate test results

./wrk -t5 -c100 -d60s -s scripts/report.lua http://172.31.4.203:8080/
Running 1m test @ http://172.31.4.203:8080/
 5 threads and 100 connections
 Thread Stats   Avg      Stdev     Max   +/- Stdev
   Latency   495.21us  241.53us  12.19ms   63.05%
   Req/Sec    40.46k     2.03k  105.04k    89.11%
 12084388 requests in 1.00m, 1.38GB read
Requests/sec: 201072.35
Transfer/sec:     23.59MB

--------------------- percentiles ----------------
50p, 483
75p, 687
90p, 772
99p, 966
99.999p, 10599
------------ bucket distribution ------------------
0us: *********
1000us: *********
2000us: *********
3000us: ****
4000us: ***
5000us: **
6000us: *
7000us: *
8000us: *
9000us: *
------------ 1 * = 100 measurements ----------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment