Bram Moolenaar <Bram@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/CAON-T_hObEODB3fs52HeDwR7PzEi7RL98BBScKTUOWRbeeM0Ng%40mail.gmail.com.
No comments:
Post a Comment