Thursday, December 27, 2012

Re: Fold expression called too often

On 2012–12–24 Christian Brabandt wrote:

Thanks a lot for the patch. I did some tests with your patch and the
alternative version Vlad provided as a gist. The results:

###############
# unpatched #
###############

SCRIPT /tmp/myfold.vim
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
439650 5.393225 MyFolds()
1 6.332249 0.939024 TextManip()

SCRIPT /tmp/foldgist.vim
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
1 0.168383 0.087497 TextManip()
2701 0.080886 MyFolds()

#############
# patched #
#############

SCRIPT /tmp/myfold.vim
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
1 0.097028 0.080014 TextManip()
1304 0.017014 MyFolds()

SCRIPT /tmp/foldgist.vim
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
1 0.087780 0.085681 TextManip()
39 0.002099 MyFolds()

TextManip() simply calls "gwip".

This shows that the gist version is about 3700% faster than mine.
The patch brings a speed gain of about 6500%. With the patch applied
the influence of the gist version is way less significant, it just
gains about 10% compared to my original version. The calls to the
fold function are greatly reduced. However, this doesn't make much
of a difference in running time and that's what counts in the end.

I'd like to see this patch in mainline vim if it doesn't break
anything. For me it works so far. This has the advantage that the
existing fold expressions do not need to be modified and are not
more complex than necessary.

Thanks to both of you for taking the time to look into this.

Marco

No comments:

Post a Comment