blob: 6321247421939c864c25eb38b2db2b8d4e476706 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
|