Module:Sandbox/Aidan9382/Benchmarker: Difference between revisions

Content deleted Content added
dont sort if you dont have to
allow specifying a custom MinTimeTaken
 
(2 intermediate revisions by the same user not shown)
Line 1:
-- In-depth execution speed benchmarker - read the /doc for more info
 
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --
-- =================================================================== --
-- This is a meta-module that hooks lots of globals, andwhich cancould be disruptive --
-- Avoid using this outside of "Show preview" testing and sandboxes --
-- Be careful including this module outside of sandboxes --
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --
-- =================================================================== --
 
-- Always use rawget/rawset on _G to bypass strict
Line 56 ⟶ 57:
FunctionTotalTimes[UniqueName] = FunctionTotalTimes[UniqueName] + CallTime
end
local MinTimeTaken = rawget(_G, "_MinTimeTaken") or 0.01
if TotalTimeTaken > .01MinTimeTaken then
table.sort(SeenModules, function(a, b)
return ModuleTotalTimes[a] > ModuleTotalTimes[b]
Line 119 ⟶ 121:
end
end
return obj
end
rawset(_G, "_BenchmarkerHooker", HookTable)