extmark_spec.lua 1.1 KB

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