2024-04-20 08:44:13 -07:00
|
|
|
local n = require('test.functional.testnvim')()
|
2022-06-16 17:22:43 -07:00
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
local clear = n.clear
|
|
|
|
local exec_lua = n.exec_lua
|
2022-06-16 17:22:43 -07:00
|
|
|
|
|
|
|
describe('treesitter perf', function()
|
|
|
|
setup(function()
|
|
|
|
clear()
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('can handle large folds', function()
|
2024-04-20 08:44:13 -07:00
|
|
|
n.command 'edit ./src/nvim/eval.c'
|
2023-12-04 15:32:39 -07:00
|
|
|
exec_lua [[
|
2022-06-16 17:22:43 -07:00
|
|
|
local parser = vim.treesitter.get_parser(0, "c", {})
|
|
|
|
vim.treesitter.highlighter.new(parser)
|
|
|
|
|
|
|
|
local function keys(k)
|
|
|
|
vim.api.nvim_feedkeys(k, 't', true)
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.opt.foldmethod = "manual"
|
|
|
|
vim.opt.lazyredraw = false
|
|
|
|
|
|
|
|
vim.cmd '1000,7000fold'
|
|
|
|
vim.cmd '999'
|
|
|
|
|
|
|
|
local function mk_keys(n)
|
|
|
|
local acc = ""
|
|
|
|
for _ = 1, n do
|
|
|
|
acc = acc .. "j"
|
|
|
|
end
|
|
|
|
for _ = 1, n do
|
|
|
|
acc = acc .. "k"
|
|
|
|
end
|
|
|
|
|
|
|
|
return "qq" .. acc .. "q"
|
|
|
|
end
|
|
|
|
|
2023-06-03 03:06:00 -07:00
|
|
|
local start = vim.uv.hrtime()
|
2022-06-16 17:22:43 -07:00
|
|
|
keys(mk_keys(10))
|
|
|
|
|
|
|
|
for _ = 1, 100 do
|
|
|
|
keys "@q"
|
|
|
|
vim.cmd'redraw!'
|
|
|
|
end
|
|
|
|
|
2023-06-03 03:06:00 -07:00
|
|
|
return vim.uv.hrtime() - start
|
2022-06-16 17:22:43 -07:00
|
|
|
]]
|
|
|
|
end)
|
|
|
|
end)
|