Tuesday, January 11, 2022

Re: vim9 Benchmark

> so speed of compilation could also matter for large scripts.

Yes, first time scripts are run they're slower, but I discarded those.


> Note that even when Vim script is a bit slower than Lua I'm still
satisfied.

I wrote my statusline in both lua and vim9, lua is 1.5x-2x faster there. Not a huge plugin, but still.
So I expect luajit to be at least a bit faster in most situations.

Anyway, repeating tests in linux I get very different results, btw (very close execution times for vim9 and luajit).

neovim:

After setting lines to range:   0.020408
After setting modified lines:   0.094530
888890

----------------------------------------
vim:
----------------------------------------
VimTest1
----------------------------------------
After setting lines to range:   0.024622
After processing loop:          0.097223
888890
----------------------------------------
VimTest2
----------------------------------------
After setting lines to range:   0.027620
After processing loop:          0.055139
After setting modified lines:   0.101768
888890

Il giorno martedì 11 gennaio 2022 alle 17:12:53 UTC+1 Dominique Pelle ha scritto:
Bram Moolenaar <Br...@moolenaar.net> wrote:
>
>
> Gianmaria Bajo wrote:
>
> > Even getting/setting lines in one go (as in the lua version) doesn't=20
> > improve it for me:
> >
> > vim9script
> >
> > def g:VimTest(): void
> > var totallen = 0
> > var start = reltime()
> > new
> > setline(1, range(100000))
> > var lines = getline(1, 100000)
> > for i in range(100000)
> > lines[i] = ' ' .. lines[i]
> > totallen += len(lines[i])
> > endfor
> > setline(1, lines)
> > echom totallen
> > echom reltimestr(reltime(start))
> > bwipe!
> > enddef
> >
> > Result:
> >
> > :call VimTest()
> > 888890
> > 0.330822
>
> You are taking it in the wrong direction. The benchmark is for a plugin
> that would go over the text and make changes here and there, e.g. adjust
> the indent. That would only change some lines, but to get it do more
> work for a more reliable measurement the benchmark changes many lines.
> Changing this to take all lines at once, change them, then set all lines
> at once, is changing what it is trying to measure.
>
> It is no surprise Lua would be faster with list manipulations. Thus if
> you shift work from interacting with the buffer lines to string
> manipulations it can be expected that using Lua is faster. In practice
> plugins do have to manipulate buffer lines, so I rather do more of that
> to have a representative benchmark.
>
> Note that even when Vim script is a bit slower than Lua I'm still
> satisfied. I expect Lua was already tweaked for performance, Vim9 is
> still young, there probably is a performance gain if we put some effort
> into it. If Vim script was ten times slower I would wonder if we are
> doing something wrong.

The 2 benchmarks in README_VIM9.md (sum and indent) have
loops with many iterations. So they only benchmark execution time
of compiled code as opposed to measuring the time to compile
the script.

I suppose that often, some functions are executed only
a few times (sometimes only once) and so speed of compilation
could also matter for large scripts. It's harder to compare
compilation time between Vim9 and LuaJIT though.

Dominique

--
--
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/0ff5fe44-7318-4750-a9dd-93dd4e7f371an%40googlegroups.com.

No comments: