Tuesday, January 11, 2022

Re: vim9 Benchmark

I repeated those tests multiple times. It seems to be a bit slower, yes.

vim9script

def VimTest1(): void
    var totallen = 0
    var start = reltime()
    new
    call setline(1, range(100000))
    for i in range(1, 100000)
        setline(i, '    ' .. getline(i))
        totallen += len(getline(i))
    endfor
    echom 'VimTest1'
    echom totallen
    echom reltimestr(reltime(start))
    bwipe!
enddef

def VimTest2(): 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 'VimTest2'
    echom totallen
    echom reltimestr(reltime(start))
    bwipe!
enddef

def g:VimTests(): void
    VimTest1()
    VimTest2()
enddef

Il giorno martedì 11 gennaio 2022 alle 14:07:55 UTC+1 cbl...@256bit.org ha scritto:

On Di, 11 Jan 2022, Gianmaria Bajo wrote:

> Even getting/setting lines in one go (as in the lua version) doesn't 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

That is even slower?



Mit freundlichen Grüßen
Christian
--
Mit welcher Geschwindigkeit breitet sich das Dunkel aus?

--
--
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/7780f3cf-95aa-4b7e-8932-166cce92a42an%40googlegroups.com.

No comments:

Post a Comment