treesitter_spec.lua 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. local n = require('test.functional.testnvim')()
  2. local clear = n.clear
  3. local exec_lua = n.exec_lua
  4. describe('treesitter perf', function()
  5. setup(function()
  6. clear()
  7. end)
  8. it('can handle large folds', function()
  9. n.command 'edit ./src/nvim/eval.c'
  10. exec_lua [[
  11. local parser = vim.treesitter.get_parser(0, "c", {})
  12. vim.treesitter.highlighter.new(parser)
  13. local function keys(k)
  14. vim.api.nvim_feedkeys(k, 't', true)
  15. end
  16. vim.opt.foldmethod = "manual"
  17. vim.opt.lazyredraw = false
  18. vim.cmd '1000,7000fold'
  19. vim.cmd '999'
  20. local function mk_keys(n)
  21. local acc = ""
  22. for _ = 1, n do
  23. acc = acc .. "j"
  24. end
  25. for _ = 1, n do
  26. acc = acc .. "k"
  27. end
  28. return "qq" .. acc .. "q"
  29. end
  30. local start = vim.uv.hrtime()
  31. keys(mk_keys(10))
  32. for _ = 1, 100 do
  33. keys "@q"
  34. vim.cmd'redraw!'
  35. end
  36. return vim.uv.hrtime() - start
  37. ]]
  38. end)
  39. end)