diff options
| author | 张杨 <[email protected]> | 2023-10-18 03:35:17 +0000 |
|---|---|---|
| committer | 陆秋文 <[email protected]> | 2023-10-18 03:35:17 +0000 |
| commit | ecc6d08170d6f4914fd90bf9fe574c657546cfae (patch) | |
| tree | b1a45b2f671d3213347be268c5787eebba1ff5b8 /bindings/rs-timeout/timeout/bench/bench-aux.lua | |
| parent | 36450f5dfa230ef806151101ee8047375915ad73 (diff) | |
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 |
