mirror of
https://github.com/kepler155c/opus
synced 2025-01-03 20:30:28 +00:00
Lua: timing
This commit is contained in:
parent
bf870479c4
commit
43163053a5
@ -6,6 +6,8 @@ local Map = { }
|
|||||||
-- TODO: refactor
|
-- TODO: refactor
|
||||||
Map.merge = Util.merge
|
Map.merge = Util.merge
|
||||||
Map.shallowCopy = Util.shallowCopy
|
Map.shallowCopy = Util.shallowCopy
|
||||||
|
Map.find = Util.find
|
||||||
|
Map.filter = Util.filter
|
||||||
|
|
||||||
function Map.removeMatches(t, values)
|
function Map.removeMatches(t, values)
|
||||||
local function matchAll(entry)
|
local function matchAll(entry)
|
||||||
|
@ -77,6 +77,9 @@ function Util.tostring(pattern, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if type(pattern) == 'string' then
|
if type(pattern) == 'string' then
|
||||||
|
if select('#', ...) == 0 then
|
||||||
|
return pattern
|
||||||
|
end
|
||||||
return _sformat(pattern, ...)
|
return _sformat(pattern, ...)
|
||||||
elseif type(pattern) == 'table' then
|
elseif type(pattern) == 'table' then
|
||||||
return serialize(pattern, term.current().getSize())
|
return serialize(pattern, term.current().getSize())
|
||||||
|
@ -294,6 +294,7 @@ end
|
|||||||
function page:rawExecute(s)
|
function page:rawExecute(s)
|
||||||
local fn, m
|
local fn, m
|
||||||
local wrapped
|
local wrapped
|
||||||
|
local t = os.clock()
|
||||||
|
|
||||||
fn = load('return (' ..s.. ')', 'lua', nil, sandboxEnv)
|
fn = load('return (' ..s.. ')', 'lua', nil, sandboxEnv)
|
||||||
|
|
||||||
@ -319,7 +320,7 @@ function page:rawExecute(s)
|
|||||||
local bg, fg = term.getBackgroundColor(), term.getTextColor()
|
local bg, fg = term.getBackgroundColor(), term.getTextColor()
|
||||||
term.setTextColor(colors.cyan)
|
term.setTextColor(colors.cyan)
|
||||||
term.setBackgroundColor(colors.black)
|
term.setBackgroundColor(colors.black)
|
||||||
term.write(string.format('out [%d]: ', counter))
|
term.write(string.format('out [%.2f]: ', os.clock() - t))
|
||||||
term.setBackgroundColor(bg)
|
term.setBackgroundColor(bg)
|
||||||
term.setTextColor(fg)
|
term.setTextColor(fg)
|
||||||
Util.print(m or 'nil')
|
Util.print(m or 'nil')
|
||||||
|
Loading…
Reference in New Issue
Block a user