Module:Sandbox/Aidan9382: Difference between revisions

Content deleted Content added
rearrange
that's cool
 
(7 intermediate revisions by the same user not shown)
Line 23:
mw.log("Aidan9382 | Unable to load Benchmarker (unexpected arg setup)")
end
end
 
function p.parentingLogic(frame)
--Note: Not even sure this thing goes beyond 1 parent, but have overcomplicated code anyways
local parentChain = {}
local newframe = frame
while true do
local parent = newframe:getParent()
if not parent then
break
end
newframe = parent
parentChain[#parentChain+1] = parent
end
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 115 ⟶ 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 136 ⟶ 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 out
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 outouts = ""{}
local start = os.clock()
for i = 1, tonumber(frame.args[2]) or 10 do
outouts[#outs+1] = out .. frame:preprocess(text) .. (frame.args[3] or "\n")
end
local duration = os.clock() - start
return out
return "Time taken: " .. duration .. "\n\n" .. table.concat(outs, frame.args[3] or "\n")
end