31 lines
981 B
Lua
31 lines
981 B
Lua
-- S3 (+S4): 80% GET single / 15% GET list / 5% POST.
|
|
-- The mix exposes the store-actor channel round-trip on urus, mutex
|
|
-- contention on axum, and gen_server message-pass on cowboy without
|
|
-- making writes the bottleneck.
|
|
|
|
local common = require("common")
|
|
wrk.headers = common.headers
|
|
wrk.headers["Content-Type"] = "application/json"
|
|
|
|
math.randomseed(os.time() + os.getpid())
|
|
|
|
-- A small pool of pre-built JSON bodies. Building one fresh per request
|
|
-- in Lua would taint the bench with Lua's GC overhead.
|
|
local body_pool = {}
|
|
for i = 1, 64 do
|
|
body_pool[i] = string.format(
|
|
[[{"name":"user%d","email":"u%d@example.test"}]], i, i)
|
|
end
|
|
|
|
request = function()
|
|
local r = math.random()
|
|
if r < 0.80 then
|
|
return wrk.format("GET", "/api/v1/users/" .. math.random(1, 10000))
|
|
elseif r < 0.95 then
|
|
return wrk.format("GET", "/api/v1/users")
|
|
else
|
|
local body = body_pool[math.random(1, #body_pool)]
|
|
return wrk.format("POST", "/api/v1/users", nil, body)
|
|
end
|
|
end
|