neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

extmark_spec.lua (1094B)


      1 local n = require('test.functional.testnvim')()
      2 
      3 local clear = n.clear
      4 local exec_lua = n.exec_lua
      5 
      6 describe('extmark perf', function()
      7  before_each(function()
      8    clear()
      9 
     10    exec_lua([[
     11      out = {}
     12      function start()
     13        ts = vim.uv.hrtime()
     14      end
     15      function stop(name)
     16        out[#out+1] = ('%14.6f ms - %s'):format((vim.uv.hrtime() - ts) / 1000000, name)
     17      end
     18    ]])
     19  end)
     20 
     21  after_each(function()
     22    for _, line in ipairs(exec_lua([[return out]])) do
     23      print(line)
     24    end
     25  end)
     26 
     27  it('repeatedly calling nvim_buf_clear_namespace #28615', function()
     28    exec_lua([[
     29      vim.api.nvim_buf_set_lines(0, 0, -1, true, { 'foo', 'bar' })
     30      local ns0 = vim.api.nvim_create_namespace('ns0')
     31      local ns1 = vim.api.nvim_create_namespace('ns1')
     32 
     33      for _ = 1, 10000 do
     34        vim.api.nvim_buf_set_extmark(0, ns0, 0, 0, {})
     35      end
     36      vim.api.nvim_buf_set_extmark(0, ns1, 1, 0, {})
     37 
     38      start()
     39      for _ = 1, 10000 do
     40        vim.api.nvim_buf_clear_namespace(0, ns1, 0, -1)
     41      end
     42      stop('nvim_buf_clear_namespace')
     43    ]])
     44  end)
     45 end)