Skip to content

Instantly share code, notes, and snippets.

@tjdevries
Last active March 4, 2021 14:10
Show Gist options
  • Save tjdevries/bd9515a44dd96dc01ea563341d907ba1 to your computer and use it in GitHub Desktop.
Save tjdevries/bd9515a44dd96dc01ea563341d907ba1 to your computer and use it in GitHub Desktop.
Some boring speed comparisons

Comparisons taken from bram's reasoning for vim9

let start = reltime()

function VimNew()
  let sum = 0
  for i in range(1, 2999999)
    let sum = sum + i
  endfor

  return sum
endfunction

echo VimNew()
echo reltimestr(reltime(start))

Result:

  • 5.195563 seconds

Generated Lua code from https://github.com/tjdevries/vim9jit

require('vim9jit')

local start = vim.fn['reltime']()

local function VimNew() local sum = 0
for i = 1, 2999999, 1 do
  sum = Vim9__Add(sum, i)
end


return sum
 end
vim.cmd(string.format([[%s%s '%s']], 'echo', "", VimNew()))
vim.cmd(string.format([[%s%s '%s']], 'echo', "", vim.fn['reltimestr'](vim.fn['reltime'](start))))

Result:

  • 0.004449 seconds

LuaJIT vs VimL 0.004 vs 5.0+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment