init function args wrk init args local filename args math randomseed o

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
init = function(args)
wrk.init(args)
local filename = args[1]
math.randomseed(os.time())
file = io.open(filename, "r")
local lines = 0
for _ in file:lines() do
lines = lines + 1
end
file:seek("set", 0);
for i=0,math.random(0, lines) do
file:read("*l");
end
log = io.open("log", "w")
wrk.headers["Connection"] = "keep-alive"
end
request = function()
local url = file:read("*l")
if url == nil then
file:seek("set", 0)
url = file:read("*l")
end
url = "/v2/800x800q75/http://" .. url
log:write(url, "\n")
res = wrk.format("GET", url)
return res
end
response = function(status, headers, body)
end
done = function(summary, latency, requests)
end