On 23/03/07 11:10 AM, Ernie Rael wrote:
On 23/03/07 9:14 AM, Bram Moolenaar wrote:
Ernie Rael wrote:


I was surprised to see a user function ~1,000 times slower.
Invoking a user function has a lot of overhead.  You did use a compiled
function?
I did. But I was uncomfortable with the results; finally this morning it occurred to me that I wasn't using the profiler correctly for micro benchmarking and I'm looking at that right now. I don't believe the function is 1,000 slower, maybe more like 100 times slower.

My hand slapping against my forehead...

Turns out the main performance issue is that I was running the test by doing "source %" in a gvim that had been running for a while. PutIfAbsent(), run from gvim that's been running for a long time, can be around 12x slower than than when run from the command line as "gvim -c 'source test.vim' -c q". Alloc/free?

And curiously, when run from the command line, gvim is 50% slower than vim. Some results below, the "command line" results are repeatable. Doing ":source" in a just started gvim, versus command line gvim, is ~20% faster, I'm guessing that's because gvim has time to get to a quiescent state before the test is run.

Note that only the user function implementation (which takes much longer than anything else) shows such a huge variation in performance. The bottom line is that the user function PutIfAbsent is ~30 times slower than extend({[k]: v}, 'keep') when run with vim from command line.

-ernie

Using running for a while gvim, :sou %
       10       30       65      100      200      300 : nKeys (micro-sec/algorithm)       293      308      305      311      318      323 : d->PutIfAbsent(k, v)     0.468    0.448    0.465    0.484    0.467    0.488 : d->extend({[k]: v}, 'keep')

Using gvim from command line
$ gvim -c 'source test.vim' -c q
    1.276    5.895   10.580   15.006   19.510   24.190 : d->PutIfAbsent(k, v)     0.479    0.476    0.473    0.464    0.477    0.493 : d->extend({[k]: v}, 'keep')

Using console vim from command line
$ vim -c 'source test.vim' -c q
    0.974    4.223    7.227   10.401   13.967   16.784 : d->PutIfAbsent(k, v)     0.478    0.476    0.464    0.469    0.471    0.491 : d->extend({[k]: v}, 'keep')

Using fresh start gvim, :sou
    1.038    4.948    8.836   12.581   16.383   20.328 : d->PutIfAbsent(k, v)     0.477    0.470    0.454    0.455    0.456    0.491 : d->extend({[k]: v}, 'keep')


--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/c5cf222b-a0c6-8fd2-3ee8-d11df6123865%40raelity.com.

Raspunde prin e-mail lui