-
-
Save yinheli/8ab78155c47916ba3570 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.
This file contains 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 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 |
This file contains 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
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