Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 June 20, 2010

Showing 2 changed files with 20 additions and 5 deletions. Show diff stats Hide diff stats

  1. 17  autoload.vim
  2. 8  publish.vim
17  autoload.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim script
2 2
 " Maintainer: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 16, 2010
  3
+" Last Change: June 20, 2010
4 4
 " URL: http://peterodding.com/code/vim/publish
5 5
 
6 6
 function! publish#resolve_files(directory, pathnames) " {{{1
@@ -20,6 +20,7 @@ function! publish#find_tags(files_to_publish) " {{{1
20 20
   " Given a dictionary like the one created above, this function will filter
21 21
   " the results of taglist() to remove irrelevant entries. In the process tag
22 22
   " search ex-commands are converted into line numbers.
  23
+  let start = xolox#timer#start()
23 24
   let num_duplicates = 0
24 25
   let tags_to_publish = {}
25 26
   let s:cached_contents = {}
@@ -50,6 +51,9 @@ function! publish#find_tags(files_to_publish) " {{{1
50 51
     call xolox#warning(msg, more, more == 1 ? '' : 's')
51 52
   endif
52 53
   unlet s:cached_contents
  54
+  let msg = "publish.vim: Found %i tag%s to publish in %s."
  55
+  let numtags = len(tags_to_publish)
  56
+  call xolox#timer#stop(msg, numtags, numtags != 1 ? 's' : '', start)
53 57
   return tags_to_publish
54 58
 endfunction
55 59
 
@@ -126,6 +130,8 @@ function! s:nasty()
126 130
 endfunction
127 131
 
128 132
 function! publish#rsync_check(target) " {{{1
  133
+  let start = xolox#timer#start()
  134
+  let result = ''
129 135
   let matches = matchlist(a:target, '^sftp://\([^/]\+\)\(.*\)$')
130 136
   if len(matches) >= 3
131 137
     let host = matches[1]
@@ -134,18 +140,21 @@ function! publish#rsync_check(target) " {{{1
134 140
     if !v:shell_error
135 141
       call system('ssh ' . host . ' rsync --version')
136 142
       if !v:shell_error
137  
-        return host . ':' . path
  143
+        let result = host . ':' . path
138 144
       endif
139 145
     endif
140 146
   endif
141  
-  return ''
  147
+  call xolox#timer#stop("publish.vim: Checked rsync support in %s.", start)
  148
+  return result
142 149
 endfunction
143 150
 
144 151
 function! publish#run_rsync(target, tempdir) " {{{1
  152
+  let start = xolox#timer#start()
145 153
   let target = fnameescape(a:target . '/')
146 154
   let tempdir = fnameescape(a:tempdir . '/')
147  
-  call xolox#message("Publishing files to %s using rsync..", a:target)
  155
+  call xolox#message("publish.vim: Uploading files to %s using rsync.", a:target)
148 156
   execute '!rsync -vr' tempdir target
  157
+  call xolox#timer#stop("publish.vim: Finished uploading in %s.", start)
149 158
   if v:shell_error
150 159
     throw "publish.vim: Failed to run rsync!"
151 160
   endif
8  publish.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim plug-in
2 2
 " Maintainer: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 16, 2010
  3
+" Last Change: June 20, 2010
4 4
 " URL: http://peterodding.com/code/vim/publish
5 5
 " License: MIT
6 6
 " Version: 1.6
@@ -57,9 +57,15 @@ function! Publish(source, target, files) abort
57 57
       silent execute 'write!' fnameescape(plaintext_path)
58 58
     endif
59 59
     silent execute 'doautocmd User PublishPre'
  60
+    let highlight_start = xolox#timer#start()
60 61
     runtime syntax/2html.vim
  62
+    let msg = "publish.vim: The 2html.vim script took %s to highlight %s."
  63
+    call xolox#timer#stop(msg, highlight_start, pathname)
61 64
     if exists('tags_to_links_command')
  65
+      let tags_to_links_start = xolox#timer#start()
62 66
       silent execute tags_to_links_command
  67
+      let msg = "publish.vim: Finished converting tags in %s to links in %s."
  68
+      call xolox#timer#stop(msg, pathname, tags_to_links_start)
63 69
     endif
64 70
     call publish#customize_html(pathname)
65 71
     silent execute 'write!' fnameescape(target_path)

0 notes on commit 514a5f7

Please sign in to comment.
Something went wrong with that request. Please try again.