Content deleted Content added
does this work |
that's cool |
||
(30 intermediate revisions by the same user not shown) | |||
Line 1:
if mw.title.getCurrentTitle().prefixedText == "Module:Sandbox/Aidan9382" then
require('Module:Module wikitext')._addText('{{User:Aidan9382/sandbox/header|nolint=y}}')
end
require("strict")
local p = {}
Line 7 ⟶ 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 ⟶ 70:
return childFrame
end
Line 143 ⟶ 83:
end
function p.
local
return "{{safesubst:#invoke:Sandbox/Aidan9382|substMagic|" .. arg+1 .. "|~~~~}}"
end
function p.SpeedTest(frame)
local text = mw.text.unstripNoWiki(frame.args[1])
local outs = {}
local start = os.clock()
for i = 1, tonumber(frame.args[2]) or 10 do
local r = tostring(math.random())
outs[#outs+1] = string.sub(frame:preprocess(text..r),1,-(1+#r))
end
local duration = os.clock() - start
return "Time taken: " .. duration .. "\n\n" .. table.concat(outs, frame.args[3] or "\n")
end
function p.
local
local outs = {}
local start = os.clock()
for i = 1, tonumber(frame.args[2]) or 10 do
outs[#outs+1] = frame:preprocess(text)
end
local duration = os.clock() - start
return "Time taken: " .. duration .. "\n\n" .. table.concat(outs, frame.args[3] or "\n")
end
function p.AnalysisTest()
repeat
local x = 5
until x == 5
end
function p.WasteExecutionTime(frame)
local t = tonumber(frame.args[1]) or 0
local start = os.clock()
while os.clock()-start < t do end
return "Wasted " .. (os.clock()-start) .. " seconds"
end
p["+expensive"] = function()
mw.incrementExpensiveFunctionCount()
return ""
end
|