rwstauner/Text-VimColor — Issue #2: Performance: mark.vim
Author: jhackworth
Created: 2012-01-13 20:49:37+00:00
State: open

Hi,

text-vimcolor works well for me, but it can take ~1-2 seconds to run.

I was taking a look at where vim is spending most of its time, and I
saw if the "Strip endline whitespace" in mark.vim is removed, it shaves
off one whole second off the execution time.

Is this whitespace stripping useful? Maybe the VimColor translation
process adds whitespace that must be removed? If not, then maybe people
are OK with the extra whitespace that was there in the input file was
still there, for the speedup here.

Thanks for the great project.

Changes
-------

Profile a change to mark.vim from Text::VimColor 0.14 (CPAN Jan 2012)
Run on Ubuntu Lucid 10.04, vim 2:7.2.330-1ubuntu3

Commenting out the string:

--- mark.vim 2012-01-13 19:01:47.337114688 +0000
+++ mark.new.vim 2012-01-13 19:03:38.969117418 +0000
@@ -62,7 +62,7 @@
endwhile

" Strip whitespace from the ends of lines
-%s:\s\+$::e
+"""%s:\s\+$::e

wincmd p
normal dd

Results in 1 second speed increase.

$ ./run.sh
+ vim -RXZ -i NONE -u NONE -N -n '+set nomodeline' md5.c -s \
vc-script.vim

real 0m1.424s
user 0m0.308s
sys 0m0.004s

+ vim -RXZ -i NONE -u NONE -N -n '+set nomodeline' md5.c -s \
vc-script.new.vim

real 0m0.424s
user 0m0.308s
sys 0m0.004s

# Generate profiles
+ vim -RXZ -i NONE -u NONE -N -n '+set nomodeline' md5.c -s \
vc-script.profile.vim
+ vim -RXZ -i NONE -u NONE -N -n '+set nomodeline' md5.c -s \
vc-script.new.profile.vim

mark.vim.prof: (1 second is spent on this line)

SCRIPT /home/jman/vimcolor0.14.marktest/mark.vim
Sourced 1 time
Total time: 1.299119
Self time: 1.294749
...
" Strip whitespace from the ends of lines
1 1.001354 %s:\s\+$::e

mark.new.vim.prof: (1 second saved)

SCRIPT /home/jman/vimcolor0.14.marktest/mark.new.vim
Sourced 1 time
Total time: 0.298189
Self time: 0.293800
...
" Strip whitespace from the ends of lines
"""%s:\s\+$::e

Reference
---------

vc-script.profile.vim: (based on /tmp script output from text-vimcolor)

:let perl_include_pod=1
:let b:is_bash=1
:filetype on

:profile start mark.vim.prof
:profile! file mark.vim

:source mark.vim
:write! md5.c.out
:qall!

md5.c: Some 434 line random C file.