fix(#1961): harden profiling functions (#1986)

This commit is contained in:
Alexander Courtis
2023-02-11 17:05:01 +11:00
committed by GitHub
parent 02fdc262eb
commit b712b82b0c
11 changed files with 44 additions and 46 deletions

View File

@@ -26,8 +26,7 @@ local function populate_children(handle, cwd, node, git_status)
local abs = utils.path_join { cwd, name }
local pn = string.format("explore populate_children %s", abs)
local ps = log.profile_start(pn)
local profile = log.profile_start("explore populate_children %s", abs)
t = get_type_from(t, abs)
if
@@ -53,7 +52,7 @@ local function populate_children(handle, cwd, node, git_status)
end
end
log.profile_end(ps, pn)
log.profile_end(profile)
end
end
@@ -64,8 +63,7 @@ function M.explore(node, status)
return
end
local pn = string.format("explore init %s", node.absolute_path)
local ps = log.profile_start(pn)
local profile = log.profile_start("explore init %s", node.absolute_path)
populate_children(handle, cwd, node, status)
@@ -76,14 +74,14 @@ function M.explore(node, status)
local ns = M.explore(child_folder_only, status)
node.nodes = ns or {}
log.profile_end(ps, pn)
log.profile_end(profile)
return ns
end
sorters.merge_sort(node.nodes, sorters.node_comparator)
live_filter.apply_filter(node)
log.profile_end(ps, pn)
log.profile_end(profile)
return node.nodes
end

View File

@@ -41,7 +41,7 @@ function M.reload(node, git_status, unloaded_bufnr)
return
end
local ps = log.profile_start("reload %s", node.absolute_path)
local profile = log.profile_start("reload %s", node.absolute_path)
local filter_status = filters.prepare(git_status, unloaded_bufnr)
@@ -130,13 +130,13 @@ function M.reload(node, git_status, unloaded_bufnr)
node.group_next = child_folder_only
local ns = M.reload(child_folder_only, git_status)
node.nodes = ns or {}
log.profile_end(ps, "reload %s", node.absolute_path)
log.profile_end(profile)
return ns
end
sorters.merge_sort(node.nodes, sorters.node_comparator)
live_filter.apply_filter(node)
log.profile_end(ps, "reload %s", node.absolute_path)
log.profile_end(profile)
return node.nodes
end
@@ -164,8 +164,7 @@ function M.refresh_nodes_for_path(path)
return
end
local pn = string.format("refresh_nodes_for_path %s", path)
local ps = log.profile_start(pn)
local profile = log.profile_start("refresh_nodes_for_path %s", path)
NodeIterator.builder({ explorer })
:hidden()
@@ -186,7 +185,7 @@ function M.refresh_nodes_for_path(path)
end)
:iterate()
log.profile_end(ps, pn)
log.profile_end(profile)
end
function M.setup(opts)