Content deleted Content added
+ some testing |
that's cool |
||
(8 intermediate revisions by the same user not shown) | |||
Line 9:
end
function p.Debug(arg1, arg2) -- General-purpose debugger/testing tool; combines multiple submodules▼
-- Runs CodeAnalysis and Benchmarker▼
-- Benchmarker expects either p and the module name or the return function and the module name▼
-- This is to be required in the module, not `#invoke:`ed▼
require('Module:Module wikitext')._addText('{{#invoke:Sandbox/Aidan9382/CodeAnalysis|main}}')▼
local Hook = require("Module:Sandbox/Aidan9382/Benchmarker")▼
local t = type(arg1) == "table" and arg1 or type(arg1) == "nil" and {} or nil▼
if t then▼
return Hook(t, arg2 or "root module")▼
elseif type(arg1) == "function" then▼
return Hook(arg1, arg2 or "root module")▼
elseif arg1 ~= false then▼
mw.log("Aidan9382 | Unable to load Benchmarker (unexpected arg setup)")▼
end
end
Line 99 ⟶ 80:
else
return "{{DEFAULTSORT:XYZ}}"
end
end
Line 120 ⟶ 90:
function p.SpeedTest(frame)
local text = mw.text.unstripNoWiki(frame.args[1])
local
local start = os.clock()
for i = 1, tonumber(frame.args[2]) or 10 do
local r = tostring(math.random())
end
local duration = os.clock() - start
return "Time taken: " .. duration .. "\n\n" .. table.concat(outs, frame.args[3] or "\n")
end
function p.SpeedTestNoRandom(frame)
local text = mw.text.unstripNoWiki(frame.args[1])
local
local start = os.clock()
for i = 1, tonumber(frame.args[2]) or 10 do
end
local duration = os.clock() - start
return "Time taken: " .. duration .. "\n\n" .. table.concat(outs, frame.args[3] or "\n")
end
Line 148 ⟶ 122:
while os.clock()-start < t do end
return "Wasted " .. (os.clock()-start) .. " seconds"
▲function p.Debug(arg1, arg2) -- General-purpose debugger/testing tool; combines multiple submodules
▲ -- Runs CodeAnalysis and Benchmarker
▲ -- Benchmarker expects either p and the module name or the return function and the module name
▲ -- This is to be required in the module, not `#invoke:`ed
▲ require('Module:Module wikitext')._addText('{{#invoke:Sandbox/Aidan9382/CodeAnalysis|main}}')
▲ local Hook = require("Module:Sandbox/Aidan9382/Benchmarker")
▲ local t = type(arg1) == "table" and arg1 or type(arg1) == "nil" and {} or nil
▲ if t then
▲ return Hook(t, arg2 or "root module")
▲ elseif type(arg1) == "function" then
▲ return Hook(arg1, arg2 or "root module")
▲ elseif arg1 ~= false then
▲ mw.log("Aidan9382 | Unable to load Benchmarker (unexpected arg setup)")
end
|