Skip to content

Commit 7fb2b8b

Browse files
committed
feat: print total time taken to load all plugins
1 parent de10915 commit 7fb2b8b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lua/packer/compile.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,20 @@ local function save_profiles(threshold)
8585
end
8686
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
8787
local results = {}
88+
local total_time = 0
8889
for i, elem in ipairs(sorted_times) do
8990
if not threshold or threshold and elem[2] > threshold then
9091
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
9192
end
93+
total_time = total_time + elem[2]
9294
end
9395
96+
if threshold then
97+
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
98+
end
99+
table.insert(results, '')
100+
table.insert(results, 'Total time: ' .. total_time .. 'ms')
101+
94102
_G._packer = _G._packer or {}
95103
_G._packer.profile_output = results
96104
end

0 commit comments

Comments
 (0)