I did two speed tests of sort() with and without my patch
on my Linux box:

        original     patched    ratio
test1  78.81 sec   81.06 sec    1.03
test2   5.87 sec    6.08 sec    1.04

where 'original' is the revision adc4a84f72eb, and
'patched' is with my patch for eval.c.

It seems the overhead by the wrapper function
item_compare_stable() is just a few percent.

The two tests are:

"----- test1.vim -----
let l = []
py <<END
import vim
import random
import time
rmax = 10000000
rnum = 10000000
l = vim.bindeval('l')
l += [ random.randint(0,rmax) for i in range(rnum) ]
t0 = time.time()
END
call sort(l)
py print time.time() - t0

"----- test2.vim -----
let l = []
py <<END
import vim
import time
l = vim.bindeval('l')
for dat in open('big.txt'):
    l += dat.strip().split()
t0 = time.time()
END
call sort(l)
py print time.time() - t0

Here, big.txt is created by
$ cat vim/runtime/doc/*.txt > big.txt
big.txt contains 843083 words, and the list l has the same
number of string elements. Test result may change if I use
other text files.

For test1, I did a few more test with different values for rmax,
and for test2 I also tried sort(l,'i'); the results were similar
(a few percent slowdown) on the Linux box.

On my Mac, on the other hand, the results were somewhat different.
For test1, the ratio is about 1.05 for rmax = 10000000, but
the ratio becomes more than 2.0 for rmax = 100 (i.e., lots of
equivalent data).
For test2, the ratio is about 1.7, i.e., the one with my patch
is about 70% slower. 
I believe these slowdown is not due to the overhead of
item_compare_stable() but due to that, in the case of qsort() on
Mac (or BSD), the number of swap is larger for the 'stable' sort
case. I think this can't be avoided by tuning the code in eval.c.



-- 
-- 
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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui