Merge branch 'fix-changelogs' into 'main'
[tor.git] / src / ext / timeouts / bench / bench-del.lua
blob4306745f218e59ae720f7ecaf8b65e8f56fc2dc8
1 #!/usr/bin/env lua
3 local bench = require"bench"
4 local aux = require"bench-aux"
6 local lib = ... or aux.optenv("BENCH_L", "bench-wheel.so")
7 local limit = tonumber(aux.optenv("BENCH_N", 1000000))
8 local step = tonumber(aux.optenv("BENCH_S", limit / 100))
9 local verbose = aux.toboolean(os.getenv("BENCH_V", false))
11 local B = bench.new(lib, count)
13 for i=0,limit,step do
14 -- add i timeouts
15 local fill_elapsed, fill_count = aux.time(B.fill, B, i, 60 * 1000000)
16 assert(i == fill_count)
18 --- delete i timeouts
19 local del_elapsed = aux.time(B.del, B, 0, fill_count)
20 assert(B:empty())
21 local del_rate = i > 0 and i / del_elapsed or 0
23 local fmt = verbose and "%d\t%f\t(%d/s)\t(fill:%f)" or "%d\t%f"
24 aux.say(fmt, i, del_elapsed, del_rate, fill_elapsed)
25 end