Tuesday, January 11, 2022

Re: vim9 Benchmark

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 software said it requires Windows 95 or better, so I installed Linux.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
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/20220111152615.8D1001C04D4%40moolenaar.net.

No comments: