diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-05-09 14:06:10 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-05-09 14:06:10 -0400 |
commit | 69380033d644d39a7369e0cd2b2cb7fd5cd7c695 (patch) | |
tree | 4c06dd268817276028ece95eeb6d1db91a7cb9a6 /src/ext/timeouts/bench/bench-expire.lua | |
parent | 641cdc345c7a0e8123cee9a7b3864b63ba389afa (diff) | |
parent | af132fc299f837f8749278099e6257cea3795e8e (diff) | |
download | tor-69380033d644d39a7369e0cd2b2cb7fd5cd7c695.tar.gz tor-69380033d644d39a7369e0cd2b2cb7fd5cd7c695.zip |
Merge branch 'timeouts_v2_squashed'
Diffstat (limited to 'src/ext/timeouts/bench/bench-expire.lua')
-rwxr-xr-x | src/ext/timeouts/bench/bench-expire.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/ext/timeouts/bench/bench-expire.lua b/src/ext/timeouts/bench/bench-expire.lua new file mode 100755 index 0000000000..3e6374ed52 --- /dev/null +++ b/src/ext/timeouts/bench/bench-expire.lua @@ -0,0 +1,29 @@ +#!/usr/bin/env lua + +local bench = require"bench" +local aux = require"bench-aux" + +local lib = ... or aux.optenv("BENCH_L", "bench-wheel.so") +local limit = tonumber(aux.optenv("BENCH_N", 1000000)) +local step = tonumber(aux.optenv("BENCH_S", limit / 100)) +-- expire 1/1000 * #timeouts per clock update +local exp_step = tonumber(aux.optenv("BENCH_E", 0.0001)) +local verbose = aux.toboolean(os.getenv("BENCH_V", false)) + +local B = require"bench".new(lib, count) + +for i=0,limit,step do + -- add i timeouts + local fill_elapsed, fill_count, fill_last = aux.time(B.fill, B, i) + + -- expire timeouts by iteratively updating clock. exp_step is the + -- approximate number of timeouts (as a fraction of the total number + -- of timeouts) that will expire per update. + local exp_elapsed, exp_count = aux.time(B.expire, B, fill_count, math.floor(fill_last * exp_step)) + assert(exp_count == i) + assert(B:empty()) + local exp_rate = i > 0 and i / exp_elapsed or 0 + + local fmt = verbose and "%d\t%f\t(%d/s)\t(fill:%f)" or "%d\t%f" + aux.say(fmt, i, exp_elapsed, exp_rate, fill_elapsed) +end |