Thursday, August 31, 2023

Re: Vim9 script performance vs. legacy

On 2023-08-31, Salman Halim <salmanhalim@gmail.com> wrote:
> On Wed, Aug 30, 2023 at 5:25 PM Lifepillar <lifepillar@lifepillar.me> wrote:
>> For a more apples-to-apples comparison, below is the execution time of
>> `libcolor.Neighbours()` from my libcolor library,³ which is a literal
>> translation of a legacy colortemplate#colorspace#k_neighbours() from
>> Colortemplate v2:
>>
>> k | Legacy Vim script | Vim 9 script
>> ---|-------------------|-------------
>> 1 | 73.8 ms | 5.1 ms
>> 10 | 648.4 ms | 42.9 ms
>> 20 | 1164.1 ms | 97.7 ms
>>
>> The advantage of Vim 9 script is very significant. The benchmarking code
>> is at the end of this message for reference.
>>
>
> This is between 11 to 15+ times faster. Interestingly, running it 20 times
> reduced the advantage slightly. Just an anomaly where the CPU started doing
> something else, d'you suppose?

That k is an argument of the function (the function finds the k colors
that are most similar to a given color). Each reported figure is an
average of ten executions. I have not reported (and not computed)
confidence intervals, so 11–15x may just be within noise limits.

Interestingly, I ran those benchmarks on a version of Vim compiled by
myself. If I use my system's Vim I get better results:

k | Legacy Vim script | Vim 9 script
---|-------------------|-------------
1 | 33.1 ms | 4.0 ms
10 | 283.9 ms | 20.7 ms
20 | 512.8 ms | 51.0 ms

The gap narrows a bit: Vim 9 script is 8–10x faster. Still quite a lot.

Now, I have to find out how to optimize my custom build...

Life.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ucqo6c%248i9%241%40ciao.gmane.io.

No comments: