From 8cb6f9d2d804b2ab4d306a23b8710962b8558f95 Mon Sep 17 00:00:00 2001 From: Godmar Back Date: Tue, 11 Aug 2020 15:03:07 -0400 Subject: [PATCH] added cs3214bench.lua --- tests/cs3214bench.lua | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/cs3214bench.lua diff --git a/tests/cs3214bench.lua b/tests/cs3214bench.lua new file mode 100644 index 0000000..ecd6607 --- /dev/null +++ b/tests/cs3214bench.lua @@ -0,0 +1,41 @@ +-- +-- Lua script to be used with wrk for CS 3214 benchmarking. +-- +-- @author godmar, CS 3214 Spring 2016 +-- +-- + +-- From: http://regex.info/blog/lua/json + +luajson = os.getenv("JSON_LUA") +JSON = (loadfile (luajson))() -- one-time load of the routines + +function prepare_stat(stat) + pc = { } + for _, p in pairs({ 50, 90, 95, 99, 99.999 }) do + pc[tostring(p)] = stat:percentile(p) + end + return { + min = stat.min, + max = stat.max, + mean = stat.mean, + stdev = stat.stdev, + percentiles = pc + } +end + +done = function(summary, latency, requests) + -- we would like to include other parameters here, such as + -- the number of threads or connections per thread, but + -- these do not appear to be accessible at this point. + result = { + summary = summary, + latency = prepare_stat(latency), + requests = prepare_stat(requests) + } + ofile = os.getenv("JSON_OUTPUT_FILE") + print (string.format("Writing results to: %s", ofile)) + local f = assert(io.open(ofile, "w")) + f:write(JSON:encode_pretty(result)) + f:close() +end