finalised script to run benchmark

This commit is contained in:
Seth Samuel 2025-02-04 17:06:30 +13:00
parent 8c6666a2bb
commit aeff3d23b8
10 changed files with 500 additions and 3 deletions

55
scripts/fullRun.lua Normal file
View file

@ -0,0 +1,55 @@
local proto = { "http://", "https://" }
local sizes = { "1kb", "10kb", "100kb", "1000kb" }
local testUrl = "test.fluffyb.net"
local tcpConnections = 50
local testLength = 60 -- in seconds
local threads = wrk.thread or 4 -- Defaulting to 4 threads if not specified
local testReason = ""
-- Storage for results
local results = {}
-- Function to run different tests
function init(args)
results = {}
end
function request()
-- Cycle through protocol and size combinations
local index = math.random(1, #proto)
local sizeIndex = math.random(1, #sizes)
local url = proto[index] .. testUrl .. "/" .. sizes[sizeIndex] .. ".file"
return wrk.format("GET", url)
end
function done(summary, latency, requests)
io.write("------------------------------\n")
-- Print request results
for _, p in ipairs({ 50, 90, 99, 99.999 }) do
local n = latency:percentile(p)
io.write(string.format("%g%%,%d\n", p, n))
end
-- Requests Per Second (RPS)
local duration_in_seconds = summary.duration / 1e6
local rps = summary.requests / duration_in_seconds
io.write(string.format("Requests per second: %.2f\n", rps))
-- Store results
table.insert(results, {
reason = testReason,
requests = summary.requests,
rps = rps,
latency_avg = latency.mean / 1000,
latency_max = latency.max / 1000
})
-- Print results
io.write("\n=== Test Summary ===\n")
for _, result in ipairs(results) do
io.write(string.format("%s - Requests: %d, RPS: %.2f, Latency (avg): %.2f ms, Latency (max): %.2f ms\n",
result.reason, result.requests, result.rps, result.latency_avg, result.latency_max))
end
end