Skip to content

Instantly share code, notes, and snippets.

@filimonov
Last active April 15, 2019 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filimonov/3fddf4a97290e0d6900f79168bc90069 to your computer and use it in GitHub Desktop.
Save filimonov/3fddf4a97290e0d6900f79168bc90069 to your computer and use it in GitHub Desktop.
Lua script for formatting output of wrk to csv
URL='http://127.0.0.1:8123/ping'
EXTRA=''
echo 'query,extra,concurrency,threads,time_started,min_req,max_req,mean_req,req_stdev,min_latency,max_latency,mean_latency,latency_stdev,50th,75th,90th,99th,99.999th,duration,requests,bytes,connect_errors,read_errors,write_errors,status_errors,timeouts' > result.csv
for CONCURRENCY in 1 2 4 8 16 32 64 128 256 512 768 1024 1280 1536 1792 2048
do
if (( $CONCURRENCY < 8 )); then
THREADS=$CONCURRENCY
else
THREADS=4
fi
printf '%s,%s,%d,%d' $URL $EXTRA $CONCURRENCY $THREADS >> result.csv
wrk -t $THREADS -c $CONCURRENCY -d 20 --latency http://127.0.0.1:8123/ping -s report.lua
sleep 20
done
done = function(summary, latency, requests)
-- open output file
f = io.open("result.csv", "a+")
--f:write("time_started",",min_req,max_req,mean_req,req_stdev,min_latency,max_latency,mean_latency,latency_stdev,50th,75th,90th,99th,99.999th,duration,requests,bytes,connect_errors,read_errors,write_errors,status_errors,timeouts\n")
f:write(string.format("%s,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%d,%d,%d,%d,%d,%d,%d,%d\n",
os.date("!%Y-%m-%dT%TZ"),
requests.min, -- minimum rps
requests.max, -- max rps
requests.mean, -- mean of rps
requests.stdev, -- standard deviation of rps
latency.min, -- minimum latency
latency.max, -- max latency
latency.mean, -- mean of latency
latency.stdev, -- standard deviation of latency
latency:percentile(50), -- 50percentile latency
latency:percentile(75), -- 75percentile latency
latency:percentile(90), -- 90percentile latency
latency:percentile(99), -- 99percentile latency
latency:percentile(99.99), -- 99percentile latency
summary["duration"], -- duration of the benchmark
summary["requests"], -- total requests during the benchmark
summary["bytes"], -- total received bytes during the benchmark
summary["errors"]["connect"], -- total socket connection errors
summary["errors"]["read"], -- total socket read errors
summary["errors"]["write"], -- total socket write errors
summary["errors"]["status"], -- total socket write errors
summary["errors"]["timeout"] -- total request timeouts
))
f:close()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment