Skip to content

Instantly share code, notes, and snippets.

@andreas-marschke
Created December 17, 2014 22:21
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save andreas-marschke/d05b47ec7055354786e4 to your computer and use it in GitHub Desktop.
Save andreas-marschke/d05b47ec7055354786e4 to your computer and use it in GitHub Desktop.
Small example LUA script for wg/wrk using a tiny JSON implementation(http://regex.info/blog/lua/json) to log test results to a file.
# Example usage with several configuration sets as in multiple connections durations and threads.
# You may go take the rest of the day off while this will run ;)
for duration in 10s 1m 10m 1h
do
for connections in 100 200 300 400 500 600
do
for thread in 1 2 3 4 5
do
wrk -d$duration -c$connections -t$thread -s wrk-script.lua http://localhost:4001/beacon/0001/demo-load-test/test/web
done
done
done
JSON = (loadfile "JSON.lua")()
wrk.scheme = "http"
wrk.host = "localhost"
wrk.port = 4001
wrk.method = "GET"
wrk.path = "/beacon/0001/demo-load-test/test/web"
wrk.headers["referer"] = "http://localhost:4000/a/b/c"
wrk.headers["dnt"] = 0
wrk.headers["accept"] = "image/*;q=0.2,image/png";
wrk.headers["accept-language"] = "de-DE,en-US;q=0.8";
wrk.headers["cookie"] = "GUID=abcdef123456890";
wrk.body = nil
done = function(summary, latency, requests)
t = {
lat_min = latency.min,
lat_max = latency.max,
lat_mean = latency.mean,
lat_stdev = latency.stdev,
duration = summary.duration,
requests = summary.requests,
bytes = summary.bytes
}
if summary.errors then
t["err_con"] = summary.errors.connect
t["err_read"] = summary.errors.read
t["err_write"] = summary.errors.write
t["err_status"] = summary.errors.status
t["err_timeout"] = summary.errors.timeout
end
filename = "stats.json"
statsfile = assert(io.open(filename, "a"))
statsfile.write(statsfile, JSON:encode(t) .. ",\n");
statsfile.close()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment