bench-del.lua 755 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env lua
  2. local bench = require"bench"
  3. local aux = require"bench-aux"
  4. local lib = ... or aux.optenv("BENCH_L", "bench-wheel.so")
  5. local limit = tonumber(aux.optenv("BENCH_N", 1000000))
  6. local step = tonumber(aux.optenv("BENCH_S", limit / 100))
  7. local verbose = aux.toboolean(os.getenv("BENCH_V", false))
  8. local B = bench.new(lib, count)
  9. for i=0,limit,step do
  10. -- add i timeouts
  11. local fill_elapsed, fill_count = aux.time(B.fill, B, i, 60 * 1000000)
  12. assert(i == fill_count)
  13. --- delete i timeouts
  14. local del_elapsed = aux.time(B.del, B, 0, fill_count)
  15. assert(B:empty())
  16. local del_rate = i > 0 and i / del_elapsed or 0
  17. local fmt = verbose and "%d\t%f\t(%d/s)\t(fill:%f)" or "%d\t%f"
  18. aux.say(fmt, i, del_elapsed, del_rate, fill_elapsed)
  19. end