Skip to content

Commit

Permalink
feat: print total time taken to load all plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
mawkler committed Jul 26, 2022
1 parent de10915 commit 7fb2b8b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/packer/compile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,20 @@ local function save_profiles(threshold)
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
local total_time = 0
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
total_time = total_time + elem[2]
end
if threshold then
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
end
table.insert(results, '')
table.insert(results, 'Total time: ' .. total_time .. 'ms')
_G._packer = _G._packer or {}
_G._packer.profile_output = results
end
Expand Down

0 comments on commit 7fb2b8b

Please sign in to comment.