diff options
Diffstat (limited to 'bindings/rs-timeout/timeout/bench/bench-aux.lua')
| -rw-r--r-- | bindings/rs-timeout/timeout/bench/bench-aux.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bindings/rs-timeout/timeout/bench/bench-aux.lua b/bindings/rs-timeout/timeout/bench/bench-aux.lua new file mode 100644 index 0000000..6321247 --- /dev/null +++ b/bindings/rs-timeout/timeout/bench/bench-aux.lua @@ -0,0 +1,30 @@ +local bench = require"bench" +local clock = bench.clock + +local aux = {} + +local function time_return(begun, ...) + local duration = clock() - begun + return duration, ... +end + +function aux.time(f, ...) + local begun = clock() + return time_return(begun, f(...)) +end + +function aux.say(...) + print(string.format(...)) +end + +function aux.toboolean(s) + return tostring(s):match("^[1TtYy]") and true or false +end + +function aux.optenv(k, def) + local s = os.getenv(k) + + return (s and #s > 0 and s) or def +end + +return aux |
