chore: add benchmarking

lsm
Jef Roosens 2023-05-31 20:39:06 +02:00
parent 62c42331d4
commit 1a8022ab34
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 56 additions and 0 deletions

View File

@ -20,3 +20,22 @@ requesting a redirect. This makes the server very fast.
I gave up giving my projects original names a long time ago, so now I just use I gave up giving my projects original names a long time ago, so now I just use
the names of my friends ;p the names of my friends ;p
## Benchmarking
I benchmark this tool using the [`wrk2`](https://github.com/giltene/wrk2)
utility. I've provided two Lua scripts to aid with this. To bench publishing
redirects, use the following:
```sh
wrk2 -s bench/post.lua -t 10 -R 10k -d30s -c32 http://localhost:18080
```
And to bench GET requests:
```sh
wrk2 -s bench/get.lua -t 10 -R 25k -d30s -c32 http://localhost:18080
```
Of course you're free to change the parameters, but the provided Lua files
generate URLs that can be used in the benchmark.

13
bench/get.lua 100644
View File

@ -0,0 +1,13 @@
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
request = function()
path = "/"
for i = 1,4 do
local rint = math.random(1, #chars)
path = path .. chars:sub(rint, rint)
end
return wrk.format(nil, path)
end

24
bench/post.lua 100644
View File

@ -0,0 +1,24 @@
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
request = function()
path = "/s/"
-- for i = 1,16 do
-- local rint = math.random(1, #chars)
-- path = path .. chars:sub(rint, rint)
-- end
body = "https://example.com/"
for i = 1,32 do
local rint = math.random(1, #chars)
body = body .. chars:sub(rint, rint)
end
wrk.path = path
wrk.method = "POST"
wrk.body = body
wrk.headers["X-Api-Key"] = "test"
return wrk.format()
end