Tuesday, January 11, 2022

Re: vim9 Benchmark

By the way, in that indent benchmark doesn't use lua as it would be done in neovim.

For example (neovim 0.6.0)

local getlines = vim.api.nvim_buf_get_lines
local setlines = vim.api.nvim_buf_set_lines
local exec = vim.cmd

function LuaTest()
  local totallen = 0
  local start = vim.fn.reltime()
  exec 'new'
  exec 'call setline(1, range(100000))'
  local bnr = vim.fn.bufnr()
  local lines = getlines(bnr, 0, -1, false)
  for i = 1, 100000 do
    lines[i] = '    ' .. lines[i]
    totallen = totallen + lines[i]:len()
  end
  setlines(bnr, 0, -1, false, lines)
  exec ('echom ' .. totallen)
  exec ('echom ' .. vim.fn.reltimestr(vim.fn.reltime(start)))
  exec 'bwipe!'
end

gVim 8.2 (patch 4058)

vim9script

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

With nvim I get:

:lua LuaTest()
888890
0.197217

With gVim I get:

:call VimTest()
888890
  0.308830

--
--
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/6a184410-c29a-44ac-b692-a585b7329c2fn%40googlegroups.com.

No comments:

Post a Comment