Gianmaria Bajo wrote:
> 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 The Lua version calls getlines() once, manipulates the array and then has one call to setlines(), the Vim version calls getline() and setline() for each line separately. That is not a good comparison. The idea of the benchmark is to manipulate the text in the buffer, using one setlines() call is not representing that. Perhaps it should be changing only every second line. -- Error:015 - Unable to exit Windows. Try the door. /// Bram Moolenaar -- b...@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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20220111123758.7F0DB1C04D4%40moolenaar.net.