fix(loader): disable profiling by default

This commit is contained in:
Lewis Russell
2023-03-31 09:43:13 +01:00
committed by GitHub
parent 5bf2f4b3c2
commit 4cff3aceea

View File

@@ -438,6 +438,13 @@ function Loader.track(stat, f)
end
end
---@class ProfileOpts
---@field loaders? boolean Add profiling to the loaders
--- Debug function that wrapps all loaders and tracks stats
---@private
---@param opts ProfileOpts?
function M._profile(opts)
Loader.get_rtp = Loader.track('get_rtp', Loader.get_rtp)
Loader.read = Loader.track('read', Loader.read)
Loader.loader = Loader.track('loader', Loader.loader)
@@ -447,14 +454,13 @@ Loader.load = Loader.track('load', Loader.load)
M.find = Loader.track('find', M.find)
Loader.lsmod = Loader.track('lsmod', Loader.lsmod)
--- Debug function that wrapps all loaders and tracks stats
---@private
function M._profile_loaders()
if opts and opts.loaders then
for l, loader in pairs(loaders) do
local loc = debug.getinfo(loader, 'Sn').source:sub(2)
loaders[l] = Loader.track('loader ' .. l .. ': ' .. loc, loader)
end
end
end
--- Prints all cache stats
---@param opts? {print?:boolean}