feat: added profiler view

This commit is contained in:
Folke Lemaitre 2022-11-29 12:02:25 +01:00
parent 08b7e42fb0
commit 20ff5fa218
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
9 changed files with 81 additions and 61 deletions

View file

@ -52,32 +52,6 @@ function M.throttle(ms, fn)
end
end
function M.profile()
local lines = { "# Profile" }
---@param entry LazyProfile
local function _profile(entry, depth)
if entry.time < 0.5 then
-- Nothing
end
table.insert(
lines,
(" "):rep(depth) .. "- " .. entry.name .. ": **" .. math.floor((entry.time or 0) / 1e6 * 100) / 100 .. "ms**"
)
for _, child in ipairs(entry) do
_profile(child, depth + 1)
end
end
for _, entry in ipairs(M._profiles[1]) do
_profile(entry, 1)
end
M.markdown(lines)
end
---@return string?
function M.head(file)
local f = io.open(file)