Skip to content

Commit 5f52ed2

Browse files
committed
Move Augment() and sorting back to Process().
1 parent d223152 commit 5f52ed2

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

autoload/startuptime.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,12 @@ function! s:Process(options, items) abort
10231023
let l:items = a:items
10241024
let l:startup = s:Startup(l:items)
10251025
let l:items = s:Consolidate(l:items)
1026+
let l:items = s:Augment(l:items, a:options)
1027+
if a:options.sort
1028+
let l:Compare = {i1, i2 ->
1029+
\ i1.time ==# i2.time ? 0 : (i1.time <# i2.time ? 1 : -1)}
1030+
call sort(l:items, l:Compare)
1031+
endif
10261032
if !empty(a:options.save)
10271033
" Saving the data is executed asynchronously with a callback. Otherwise,
10281034
" when s:Process is called through startuptime#Main, 'eventignore' would
@@ -1053,12 +1059,6 @@ function! startuptime#Main(file, winid, bufnr, options, items) abort
10531059
let l:event_width = g:startuptime_event_width
10541060
try
10551061
let [l:items, l:startup] = s:Process(a:options, a:items)
1056-
let l:items = s:Augment(l:items, a:options)
1057-
if a:options.sort
1058-
let l:Compare = {i1, i2 ->
1059-
\ i1.time ==# i2.time ? 0 : (i1.time <# i2.time ? 1 : -1)}
1060-
call sort(l:items, l:Compare)
1061-
endif
10621062
let l:processing_finished = 1
10631063
" Set 'modifiable' after :redraw so that e.g., if modifiable shows in
10641064
" the status line, it's display is not changed for the duration of

doc/startuptime.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ following example shows a `sourcing` event and an `other` event:
223223
'mean': 0.006
224224
},
225225
'event': '--- NVIM STARTING ---',
226+
'time': 0.006,
226227
'tries': 1,
227228
'type': 1,
228229
'start': {
@@ -246,6 +247,7 @@ following example shows a `sourcing` event and an `other` event:
246247
'mean': 0.053
247248
},
248249
'type': 0,
250+
'time': 0.053,
249251
'tries': 1,
250252
'event': 'sourcing .../nvim/runtime/filetype.lua',
251253
'start': {

tests/test_startuptime.vim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@ call assert_true(len(g:save1.items) ># 1)
1818
for s:item in g:save1.items
1919
if s:item.type ==# g:save1.types['sourcing']
2020
call assert_equal(
21-
\ ['event', 'finish', 'occurrence', 'self', 'self+sourced', 'start', 'tries', 'type'],
21+
\ ['event', 'finish', 'occurrence', 'self', 'self+sourced', 'start', 'time', 'tries', 'type'],
2222
\ sort(copy(keys(s:item))))
2323
call assert_equal(v:t_float, type(s:item['self+sourced'].mean))
2424
call assert_equal(v:t_float, type(s:item['self'].mean))
2525
call assert_false(isnan(s:item['self+sourced'].std))
2626
call assert_false(isnan(s:item['self'].std))
27+
call assert_equal(s:item['self+sourced'].mean, s:item['time'])
2728
elseif s:item.type ==# g:save1.types['other']
2829
call assert_equal(
29-
\ ['elapsed', 'event', 'finish', 'occurrence', 'start', 'tries', 'type'],
30+
\ ['elapsed', 'event', 'finish', 'occurrence', 'start', 'time', 'tries', 'type'],
3031
\ sort(copy(keys(s:item))))
3132
call assert_equal(v:t_float, type(s:item['elapsed'].mean))
3233
call assert_false(isnan(s:item['elapsed'].std))
34+
call assert_equal(s:item['elapsed'].mean, s:item['time'])
3335
else
3436
throw 'vim-startuptime: unknown type'
3537
endif
@@ -67,18 +69,20 @@ call assert_true(len(g:save2.items) ># 1)
6769
for s:item in g:save2.items
6870
if s:item.type ==# g:save2.types['sourcing']
6971
call assert_equal(
70-
\ ['event', 'finish', 'occurrence', 'self', 'self+sourced', 'start', 'tries', 'type'],
72+
\ ['event', 'finish', 'occurrence', 'self', 'self+sourced', 'start', 'time', 'tries', 'type'],
7173
\ sort(copy(keys(s:item))))
7274
call assert_equal(v:t_float, type(s:item['self+sourced'].mean))
7375
call assert_equal(v:t_float, type(s:item['self'].mean))
7476
call assert_true(isnan(s:item['self+sourced'].std))
7577
call assert_true(isnan(s:item['self'].std))
78+
call assert_equal(s:item['self+sourced'].mean, s:item['time'])
7679
elseif s:item.type ==# g:save2.types['other']
7780
call assert_equal(
78-
\ ['elapsed', 'event', 'finish', 'occurrence', 'start', 'tries', 'type'],
81+
\ ['elapsed', 'event', 'finish', 'occurrence', 'start', 'time', 'tries', 'type'],
7982
\ sort(copy(keys(s:item))))
8083
call assert_equal(v:t_float, type(s:item['elapsed'].mean))
8184
call assert_true(isnan(s:item['elapsed'].std))
85+
call assert_equal(s:item['elapsed'].mean, s:item['time'])
8286
else
8387
throw 'vim-startuptime: unknown type'
8488
endif

0 commit comments

Comments
 (0)