Skip to content

Commit 5e4c41a

Browse files
committed
Order by start time when output is not sorted.
Also, report 'start' and 'finish' times, and remove 'clock' (which was the same as 'finish').
1 parent 48c9dcd commit 5e4c41a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

autoload/startuptime.vim

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let s:sourcing_event_type = 0
66
let s:other_event_type = 1
77

88
" 's:tfields' contains the time fields.
9-
let s:tfields = ['elapsed', 'self+sourced', 'self', 'clock']
9+
let s:tfields = ['start', 'elapsed', 'self', 'self+sourced', 'finish']
1010

1111
let s:col_names = ['event', 'time', 'percent', 'plot']
1212
let s:widths = {
@@ -292,17 +292,20 @@ function! s:Extract(file, options) abort
292292
else
293293
let l:occurrences[l:key] = 1
294294
endif
295+
" 'finish' time is reported as 'clock' in --startuptime output.
295296
let l:item = {
296297
\ 'event': l:event,
297298
\ 'occurrence': l:occurrences[l:key],
298-
\ 'clock': str2float(l:times[0]),
299+
\ 'finish': str2float(l:times[0]),
299300
\ 'type': l:type
300301
\ }
301302
if l:type ==# s:sourcing_event_type
302303
let l:item['self+sourced'] = str2float(l:times[1])
303304
let l:item.self = str2float(l:times[2])
305+
let l:item.start = l:item.finish - l:item['self+sourced']
304306
else
305307
let l:item.elapsed = str2float(l:times[1])
308+
let l:item.start = l:item.finish - l:item.elapsed
306309
endif
307310
let l:types = []
308311
if a:options.sourcing_events
@@ -328,7 +331,7 @@ function! s:Startup(items) abort
328331
\ s:other_event_type: 'elapsed'
329332
\ }
330333
let l:key = l:lookup[l:last.type]
331-
call add(l:times, l:last.clock)
334+
call add(l:times, l:last.finish)
332335
endfor
333336
let l:mean = s:Mean(l:times)
334337
let l:std = s:StandardDeviation(l:times, 1, l:mean)
@@ -375,8 +378,8 @@ function! s:Consolidate(items) abort
375378
endfor
376379
endfor
377380
let l:Compare = {i1, i2 ->
378-
\ i1.clock.mean ==# i2.clock.mean
379-
\ ? 0 : (i1.clock.mean <# i2.clock.mean ? -1 : 1)}
381+
\ i1.start.mean ==# i2.start.mean
382+
\ ? 0 : (i1.start.mean <# i2.start.mean ? -1 : 1)}
380383
call sort(l:result, l:Compare)
381384
return l:result
382385
endfunction

0 commit comments

Comments
 (0)