Fix elapsed time to include the time spent in post-update hook

This commit is contained in:
Junegunn Choi 2014-07-27 11:15:13 +09:00
parent b2208640d4
commit e741d02ad0

View file

@ -519,6 +519,7 @@ function! s:names(...)
endfunction endfunction
function! s:update_impl(pull, args) abort function! s:update_impl(pull, args) abort
let st = reltime()
let args = copy(a:args) let args = copy(a:args)
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
\ remove(args, -1) : get(g:, 'plug_threads', 16) \ remove(args, -1) : get(g:, 'plug_threads', 16)
@ -579,6 +580,7 @@ function! s:update_impl(pull, args) abort
call plug#end() call plug#end()
endif endif
call s:finish(a:pull) call s:finish(a:pull)
call setline(1, "Updated. Elapsed time: " . split(reltimestr(reltime(st)))[0] . ' sec.')
endfunction endfunction
function! s:extend(names) function! s:extend(names)
@ -606,7 +608,6 @@ function! s:update_progress(pull, cnt, bar, total)
endfunction endfunction
function! s:update_serial(pull, todo) function! s:update_serial(pull, todo)
let st = reltime()
let base = g:plug_home let base = g:plug_home
let todo = copy(a:todo) let todo = copy(a:todo)
let total = len(todo) let total = len(todo)
@ -657,8 +658,6 @@ function! s:update_serial(pull, todo)
break break
endif endif
endwhile endwhile
call setline(1, "Updated. Elapsed time: " . split(reltimestr(reltime(st)))[0] . ' sec.')
endfunction endfunction
function! s:update_parallel(pull, todo, threads) function! s:update_parallel(pull, todo, threads)
@ -689,7 +688,6 @@ function! s:update_parallel(pull, todo, threads)
require 'fileutils' require 'fileutils'
require 'timeout' require 'timeout'
running = true running = true
st = Time.now
iswin = VIM::evaluate('s:is_win').to_i == 1 iswin = VIM::evaluate('s:is_win').to_i == 1
pull = VIM::evaluate('a:pull').to_i == 1 pull = VIM::evaluate('a:pull').to_i == 1
base = VIM::evaluate('g:plug_home') base = VIM::evaluate('g:plug_home')
@ -875,7 +873,6 @@ function! s:update_parallel(pull, todo, threads)
end end
refresh.kill if refresh refresh.kill if refresh
watcher.kill watcher.kill
$curbuf[1] = "Updated. Elapsed time: #{"%.6f" % (Time.now - st)} sec."
EOF EOF
endfunction endfunction