Module:Sandbox/Aidan9382: Difference between revisions

Content deleted Content added
rmv old/test/unneeded code
that's cool
 
(13 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
function p.parentingLogic(frame)
-- Runs CodeAnalysis and Benchmarker
--Note: Not even sure this thing goes beyond 1 parent, but have overcomplicated code anyways
-- Benchmarker expects either p and the module name or the return function and the module name
local parentChain = {}
-- This is to be required in the module, not `#invoke:`ed
local newframe = frame
require('Module:Module wikitext')._addText('{{#invoke:Sandbox/Aidan9382/CodeAnalysis|main}}')
while true do
local Hook = require("Module:Sandbox/Aidan9382/Benchmarker")
local parent = newframe:getParent()
local t = type(arg1) == "table" and arg1 or type(arg1) == "nil" and {} or nil
if not parent then
if ct then
break
return Hook(t, arg2 or "root module")
end
elseif args.returnprocesstype(arg1) == "yfunction" then
newframe = parent
return Hook(arg1, arg2 or "root module")
parentChain[#parentChain+1] = parent
elseif arg1 ~= false then
end
mw.log("Aidan9382 | Unable to load Benchmarker (unexpected arg setup)")
local parentText = ""
for i,p in next,parentChain do
parentText = parentText .. " parent"..i.."="..p:getTitle()
end
return "frame="..frame:getTitle()..parentText.." mw.gct="..mw.title.getCurrentTitle().text
end
 
p["module-use"] = function(frame)
local parentLogicStuff = p.parentingLogic(frame)
local testlogic = "\n\n"
local i = 1
while true do
local c = frame.args["_test"..i]
if c then
testlogic = testlogic .. "_test"..i.."="..c
else
break
end
i = i + 1
end
return parentLogicStuff..testlogic
end
 
Line 97 ⟶ 80:
else
return "{{DEFAULTSORT:XYZ}}"
end
end
 
function p.magicWordTests2(frame)
local args = frame.args
if args.process == "y" then
frame:preprocess("{{#assessment:Testing|B|Low}}")
elseif args.returnprocess == "y" then
return frame:preprocess("{{#assessment:Testing|B|Low}}")
else
return "{{#assessment:Testing|B|Low}}"
end
end
Line 118 ⟶ 90:
function p.SpeedTest(frame)
local text = mw.text.unstripNoWiki(frame.args[1])
local outouts = ""{}
local start = os.clock()
for i = 1, tonumber(frame.args[2]) or 10) do
local r = tostring(math.random())
outouts[#outs+1] = out .. string.sub(frame:preprocess(text..r),1,-(1+#r)) .. (frame.args[3] or "\n")
end
local duration = os.clock() - start
return "Time taken: " .. duration .. "\n\n" .. table.concat(outs, frame.args[3] or "\n")
end
 
function p.parentingLogicSpeedTestNoRandom(frame)
local text = mw.text.unstripNoWiki(frame.args[1])
local parentChainouts = {}
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 out
return "Time taken: " .. duration .. "\n\n" .. table.concat(outs, frame.args[3] or "\n")
end
 
Line 137 ⟶ 122:
while os.clock()-start < t do end
return "Wasted " .. (os.clock()-start) .. " seconds"
end
 
p["module-use+expensive"] = function(frame)
mw.incrementExpensiveFunctionCount()
return out""
end