Mercurial
comparison third_party/wrk/scripts/addr.lua @ 178:94705b5986b3
[ThirdParty] Added WRK and luajit for load testing.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Thu, 22 Jan 2026 20:10:30 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 177:24fe8ff94056 | 178:94705b5986b3 |
|---|---|
| 1 -- example script that demonstrates use of setup() to pass | |
| 2 -- a random server address to each thread | |
| 3 | |
| 4 local addrs = nil | |
| 5 | |
| 6 function setup(thread) | |
| 7 if not addrs then | |
| 8 addrs = wrk.lookup(wrk.host, wrk.port or "http") | |
| 9 for i = #addrs, 1, -1 do | |
| 10 if not wrk.connect(addrs[i]) then | |
| 11 table.remove(addrs, i) | |
| 12 end | |
| 13 end | |
| 14 end | |
| 15 | |
| 16 thread.addr = addrs[math.random(#addrs)] | |
| 17 end | |
| 18 | |
| 19 function init(args) | |
| 20 local msg = "thread addr: %s" | |
| 21 print(msg:format(wrk.thread.addr)) | |
| 22 end |