Tuesday, August 29, 2023

Re: Vim9 script performance vs. legacy

On Di, 29 Aug 2023, Salman Halim wrote:

> Hello,
>
> I've been writing my scripts using Vim 9 recently (though without classes) and
> was wondering if anybody had any performance metrics/benchmarks they would be
> willing to share that compare Vim 9's speed compared to the same thing written
> in legacy code.
>
> I find that a significant amount of my script-writing time is used in calling
> functions such as matchlist, popup_create and the such, which seem to me to be
> identical (unless you tell me that Vim 9 has access to more optimised version
> of these).
>
> Maybe the 'for' loop where I iterate over a list of strings is faster in Vim 9
> because it's both compiled and statically typed?
>
> One of the things that caught me recently was that popup_create takes a
> parameter called 'line' which can be either a number or the word 'cursor'. It
> cannot be the STRING '2', it has to be the NUMBER 2 while 'cursor' is a string.
> In legacy script, no problem. Here, I had to make it a string variable and then
> see do something like 'lineNumber != "cursor" ? str2nr(lineNumber) :
> lineNumber' to convert it to a number if needed. i'm trying to figure out
> whether there is a measurable speed advantage to going through these motions or
> if I should just write my scripts in legacy Vim script.
>
> What do people use for their own stuff these days?

I haven't done any measurements but I noticed converting to Vim9 script
helps, if you are calling your scripts many times.

So I have rewritten parts of vim-airline for those parts, that are
executed many many times and that are known to cause performance
degrations (see https://github.com/vim-airline/vim-airline/wiki/FAQ)

Best,
Christian
--
<knghtbrd> add a GF2/3, a sizable hard drive, and a 15" flat panel and
you've got a pretty damned portable machine.
<Coderjoe> a GeForce Two-Thirds?
<knghtbrd> Coderjoe: yes, a GeForce two-thirds, ie, any card from ATI.

--
--
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/ZO4BnSEOwkNkw7Hj%40256bit.org.

No comments: