comparison third_party/wrk/scripts/addr.lua @ 186:8cf4ec5e2191 hg-web

Fixed merge conflict.
author MrJuneJune <me@mrjunejune.com>
date Fri, 23 Jan 2026 22:38:59 -0800
parents 94705b5986b3
children
comparison
equal deleted inserted replaced
176:fed99fc04e12 186:8cf4ec5e2191
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