Mercurial > urweb
annotate caching-tests/bench.lua @ 2297:6d56080f495c
Fix a read-after-free bug using a timestamp check
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 19 Nov 2015 13:18:58 -0500 |
parents | 23eaec04e0f8 |
children |
rev | line source |
---|---|
ziv@2292 | 1 math.randomseed(os.time()) |
ziv@2292 | 2 |
ziv@2292 | 3 p = 0.25 |
ziv@2292 | 4 n = 2000 |
ziv@2292 | 5 |
ziv@2292 | 6 function init(args) |
ziv@2292 | 7 if args[1] then |
ziv@2292 | 8 p = tonumber(args[1]) |
ziv@2292 | 9 end |
ziv@2292 | 10 if args[2] then |
ziv@2292 | 11 n = tonumber(args[2]) |
ziv@2292 | 12 end |
ziv@2292 | 13 end |
ziv@2292 | 14 |
ziv@2292 | 15 function request() |
ziv@2292 | 16 path = "/Bench/" |
ziv@2292 | 17 if math.random() < p then |
ziv@2292 | 18 path = path .. "flush" |
ziv@2292 | 19 else |
ziv@2292 | 20 path = path .. "check" |
ziv@2292 | 21 end |
ziv@2292 | 22 id = math.random(n) |
ziv@2292 | 23 path = path .. "/" .. id |
ziv@2292 | 24 return wrk.format(nil, path) |
ziv@2292 | 25 end |