Skip to content

Commit

Permalink
fix(#549): add more profiling ~tree init
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-courtis committed Dec 16, 2022
1 parent 899ed45 commit 95ed588
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/nvim-tree/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ local events = require "nvim-tree.events"
local explorer = require "nvim-tree.explorer"
local live_filter = require "nvim-tree.live-filter"
local view = require "nvim-tree.view"
local log = require "nvim-tree.log"

local M = {}

TreeExplorer = nil
local first_init_done = false

function M.init(foldername)
local pn = string.format("core init %s", foldername)
local ps = log.profile_start(pn)

if TreeExplorer then
TreeExplorer:destroy()
end
Expand All @@ -17,6 +21,7 @@ function M.init(foldername)
events._dispatch_ready()
first_init_done = true
end
log.profile_end(ps, pn)
end

function M.get_explorer()
Expand Down
8 changes: 8 additions & 0 deletions lua/nvim-tree/explorer/explore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local sorters = require "nvim-tree.explorer.sorters"
local filters = require "nvim-tree.explorer.filters"
local live_filter = require "nvim-tree.live-filter"
local notify = require "nvim-tree.notify"
local log = require "nvim-tree.log"

local M = {}

Expand Down Expand Up @@ -61,6 +62,9 @@ function M.explore(node, status)
return
end

local pn = string.format("explore init %s", node.absolute_path)
local ps = log.profile_start(pn)

populate_children(handle, cwd, node, status)

local is_root = not node.parent
Expand All @@ -69,11 +73,15 @@ function M.explore(node, status)
node.group_next = child_folder_only
local ns = M.explore(child_folder_only, status)
node.nodes = ns or {}

log.profile_end(ps, pn)
return ns
end

sorters.merge_sort(node.nodes, sorters.node_comparator)
live_filter.apply_filter(node)

log.profile_end(ps, pn)
return node.nodes
end

Expand Down
6 changes: 6 additions & 0 deletions lua/nvim-tree/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local M = {}

local events = require "nvim-tree.events"
local utils = require "nvim-tree.utils"
local log = require "nvim-tree.log"

local function get_win_sep_hl()
-- #1221 WinSeparator not present in nvim 0.6.1 and some builds of 0.7.0
Expand Down Expand Up @@ -231,6 +232,9 @@ function M.open(options)
return
end

local pn = string.format "view open"
local ps = log.profile_start(pn)

create_buffer()
open_window()
M.resize()
Expand All @@ -240,6 +244,8 @@ function M.open(options)
vim.cmd "wincmd p"
end
events._dispatch_on_tree_open()

log.profile_end(ps, pn)
end

local function grow()
Expand Down

0 comments on commit 95ed588

Please sign in to comment.