Module:TestModule: Difference between revisions

From Kerbal Space Program 2 Wiki
Jump to navigation Jump to search
testing module, using to identify expensive parser functions in Data pulls
 
mw.loadJsonData is increasing the expensive parser function count, but do multiple in a module each count?
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:


function p.getData(frame)
function p.getData(frame)
-- Get arguments from the invoke
-- Load the data from the JSON page, parsed as a table of tables
-- E.g., args = {"Example/engine", "modules", "engine", "isp", "vac"}
local dataJson = mw.loadJsonData('GameData:LV-SW_"SWERV"')
local args = getArgs(frame, {frameOnly = true})
local dataJson2 = mw.loadJsonData('GameData:LV-N_"Nerv"')
-- Pass arguments to the helper function
dataJson = 'test output'
dataJson = p._getData(args)
dataJson2 = 'more output'
return dataJson
-- Send the final, requested value back to the main function
end
return dataJson .. " " .. dataJson2
 
function p._getData(args)
return "test output"
end
end


return p
return p

Latest revision as of 16:46, 29 March 2025

Documentation for this module may be created at Module:TestModule/doc

local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.getData(frame)
	-- Load the data from the JSON page, parsed as a table of tables
	local dataJson = mw.loadJsonData('GameData:LV-SW_"SWERV"')
	local dataJson2 = mw.loadJsonData('GameData:LV-N_"Nerv"')
	dataJson = 'test output'
	dataJson2 = 'more output'
	-- Send the final, requested value back to the main function
	return dataJson .. " " .. dataJson2
end

return p