aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/benchmark/extmark_spec.lua45
-rw-r--r--test/functional/api/extmark_spec.lua18
2 files changed, 63 insertions, 0 deletions
diff --git a/test/benchmark/extmark_spec.lua b/test/benchmark/extmark_spec.lua
new file mode 100644
index 0000000000..0d284b363c
--- /dev/null
+++ b/test/benchmark/extmark_spec.lua
@@ -0,0 +1,45 @@
+local n = require('test.functional.testnvim')()
+
+local clear = n.clear
+local exec_lua = n.exec_lua
+
+describe('extmark perf', function()
+ before_each(function()
+ clear()
+
+ exec_lua([[
+ out = {}
+ function start()
+ ts = vim.uv.hrtime()
+ end
+ function stop(name)
+ out[#out+1] = ('%14.6f ms - %s'):format((vim.uv.hrtime() - ts) / 1000000, name)
+ end
+ ]])
+ end)
+
+ after_each(function()
+ for _, line in ipairs(exec_lua([[return out]])) do
+ print(line)
+ end
+ end)
+
+ it('repeatedly calling nvim_buf_clear_namespace #28615', function()
+ exec_lua([[
+ vim.api.nvim_buf_set_lines(0, 0, -1, true, { 'foo', 'bar' })
+ local ns0 = vim.api.nvim_create_namespace('ns0')
+ local ns1 = vim.api.nvim_create_namespace('ns1')
+
+ for _ = 1, 10000 do
+ vim.api.nvim_buf_set_extmark(0, ns0, 0, 0, {})
+ end
+ vim.api.nvim_buf_set_extmark(0, ns1, 1, 0, {})
+
+ start()
+ for _ = 1, 10000 do
+ vim.api.nvim_buf_clear_namespace(0, ns1, 0, -1)
+ end
+ stop('nvim_buf_clear_namespace')
+ ]])
+ end)
+end)
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index 70bdb050e5..965a60417a 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -1896,6 +1896,24 @@ describe('Extmarks buffer api with many marks', function()
end
eq(ns_marks[ns1], get_marks(ns1))
eq(ns_marks[ns2], get_marks(ns2))
+
+ api.nvim_buf_clear_namespace(0, ns1, 0, 10)
+ for id, mark in pairs(ns_marks[ns1]) do
+ if mark[1] < 10 then
+ ns_marks[ns1][id] = nil
+ end
+ end
+ eq(ns_marks[ns1], get_marks(ns1))
+ eq(ns_marks[ns2], get_marks(ns2))
+
+ api.nvim_buf_clear_namespace(0, ns1, 20, -1)
+ for id, mark in pairs(ns_marks[ns1]) do
+ if mark[1] >= 20 then
+ ns_marks[ns1][id] = nil
+ end
+ end
+ eq(ns_marks[ns1], get_marks(ns1))
+ eq(ns_marks[ns2], get_marks(ns2))
end)
it('can delete line', function()