Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Sprinkled some xolox#timer#* calls throughout..

I added the timer calls in an attempt to determine what's slowing the
plug-in down, because right now the plug-in takes about a minute to
publish 12 files (totaling 1774 lines, ~ 57 KB). The slowest two
components in my Vim setup appear to be the 2html script and the
HighlightTags command from my easytags.vim plug-in. Fortunately I know
how to speed up the HighlightTags command significantly, so I'll just
bite the bullet, write the code and see how that goes.

BTW. While adding and testing the timer calls I noticed that Vim was
losing my message history (I could only see the timer messages for the
latest published file, all previous messages were lost). Unless my
understanding of :messages, :echomsg and :redraw is incorrect this looks
like a bug in Vim but until I can find the time to properly debug this
issue I just added a ring buffer (size: 100 by default) to the function
xolox#message() which is used by xolox#timer#stop() to print messages.
  • Loading branch information...
commit 514a5f7be3b5d09dc8a944fd594ce1fbd0e17e1b 1 parent 41da092
Peter Odding authored
Showing with 20 additions and 5 deletions.
  1. +13 −4 autoload.vim
  2. +7 −1 publish.vim
17 autoload.vim
View
@@ -1,6 +1,6 @@
" Vim script
" Maintainer: Peter Odding <peter@peterodding.com>
-" Last Change: June 16, 2010
+" Last Change: June 20, 2010
" URL: http://peterodding.com/code/vim/publish
function! publish#resolve_files(directory, pathnames) " {{{1
@@ -20,6 +20,7 @@ function! publish#find_tags(files_to_publish) " {{{1
" Given a dictionary like the one created above, this function will filter
" the results of taglist() to remove irrelevant entries. In the process tag
" search ex-commands are converted into line numbers.
+ let start = xolox#timer#start()
let num_duplicates = 0
let tags_to_publish = {}
let s:cached_contents = {}
@@ -50,6 +51,9 @@ function! publish#find_tags(files_to_publish) " {{{1
call xolox#warning(msg, more, more == 1 ? '' : 's')
endif
unlet s:cached_contents
+ let msg = "publish.vim: Found %i tag%s to publish in %s."
+ let numtags = len(tags_to_publish)
+ call xolox#timer#stop(msg, numtags, numtags != 1 ? 's' : '', start)
return tags_to_publish
endfunction
@@ -126,6 +130,8 @@ function! s:nasty()
endfunction
function! publish#rsync_check(target) " {{{1
+ let start = xolox#timer#start()
+ let result = ''
let matches = matchlist(a:target, '^sftp://\([^/]\+\)\(.*\)$')
if len(matches) >= 3
let host = matches[1]
@@ -134,18 +140,21 @@ function! publish#rsync_check(target) " {{{1
if !v:shell_error
call system('ssh ' . host . ' rsync --version')
if !v:shell_error
- return host . ':' . path
+ let result = host . ':' . path
endif
endif
endif
- return ''
+ call xolox#timer#stop("publish.vim: Checked rsync support in %s.", start)
+ return result
endfunction
function! publish#run_rsync(target, tempdir) " {{{1
+ let start = xolox#timer#start()
let target = fnameescape(a:target . '/')
let tempdir = fnameescape(a:tempdir . '/')
- call xolox#message("Publishing files to %s using rsync..", a:target)
+ call xolox#message("publish.vim: Uploading files to %s using rsync.", a:target)
execute '!rsync -vr' tempdir target
+ call xolox#timer#stop("publish.vim: Finished uploading in %s.", start)
if v:shell_error
throw "publish.vim: Failed to run rsync!"
endif
8 publish.vim
View
@@ -1,6 +1,6 @@
" Vim plug-in
" Maintainer: Peter Odding <peter@peterodding.com>
-" Last Change: June 16, 2010
+" Last Change: June 20, 2010
" URL: http://peterodding.com/code/vim/publish
" License: MIT
" Version: 1.6
@@ -57,9 +57,15 @@ function! Publish(source, target, files) abort
silent execute 'write!' fnameescape(plaintext_path)
endif
silent execute 'doautocmd User PublishPre'
+ let highlight_start = xolox#timer#start()
runtime syntax/2html.vim
+ let msg = "publish.vim: The 2html.vim script took %s to highlight %s."
+ call xolox#timer#stop(msg, highlight_start, pathname)
if exists('tags_to_links_command')
+ let tags_to_links_start = xolox#timer#start()
silent execute tags_to_links_command
+ let msg = "publish.vim: Finished converting tags in %s to links in %s."
+ call xolox#timer#stop(msg, pathname, tags_to_links_start)
endif
call publish#customize_html(pathname)
silent execute 'write!' fnameescape(target_path)
Please sign in to comment.
Something went wrong with that request. Please try again.