From 95ed5882114ab481e93362aa74c0f3c65dc4aade Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Fri, 16 Dec 2022 12:12:06 +1100 Subject: [PATCH] fix(#549): add more profiling ~tree init --- lua/nvim-tree/core.lua | 5 +++++ lua/nvim-tree/explorer/explore.lua | 8 ++++++++ lua/nvim-tree/view.lua | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/lua/nvim-tree/core.lua b/lua/nvim-tree/core.lua index a61fea72..3e5965c8 100644 --- a/lua/nvim-tree/core.lua +++ b/lua/nvim-tree/core.lua @@ -2,6 +2,7 @@ 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 = {} @@ -9,6 +10,9 @@ 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 @@ -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() diff --git a/lua/nvim-tree/explorer/explore.lua b/lua/nvim-tree/explorer/explore.lua index da0803c8..a15e6ffe 100644 --- a/lua/nvim-tree/explorer/explore.lua +++ b/lua/nvim-tree/explorer/explore.lua @@ -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 = {} @@ -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 @@ -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 diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index c2b2a75d..47cb3439 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -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 @@ -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() @@ -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()