diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
commit | ff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch) | |
tree | 729bbcb92231538fa61dab6c3d890b025484b7f5 /test/benchmark | |
parent | 376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff) | |
parent | 28c04948a1c887a1cc0cb64de79fa32631700466 (diff) | |
download | rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2 rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/benchmark')
-rw-r--r-- | test/benchmark/autocmd_spec.lua | 6 | ||||
-rw-r--r-- | test/benchmark/bench_regexp_spec.lua | 7 | ||||
-rw-r--r-- | test/benchmark/extmark_spec.lua | 45 | ||||
-rw-r--r-- | test/benchmark/preload.lua | 2 | ||||
-rw-r--r-- | test/benchmark/screenpos_spec.lua | 18 | ||||
-rw-r--r-- | test/benchmark/treesitter_spec.lua | 8 |
6 files changed, 67 insertions, 19 deletions
diff --git a/test/benchmark/autocmd_spec.lua b/test/benchmark/autocmd_spec.lua index b3421d86eb..af5fa1c258 100644 --- a/test/benchmark/autocmd_spec.lua +++ b/test/benchmark/autocmd_spec.lua @@ -1,7 +1,7 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() -local clear = helpers.clear -local exec_lua = helpers.exec_lua +local clear = n.clear +local exec_lua = n.exec_lua local N = 7500 diff --git a/test/benchmark/bench_regexp_spec.lua b/test/benchmark/bench_regexp_spec.lua index 4a7c50557b..2c2b8dc359 100644 --- a/test/benchmark/bench_regexp_spec.lua +++ b/test/benchmark/bench_regexp_spec.lua @@ -1,8 +1,9 @@ -- Test for benchmarking the RE engine. -local helpers = require('test.functional.helpers')(after_each) -local insert, source = helpers.insert, helpers.source -local clear, command = helpers.clear, helpers.command +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, command = n.clear, n.command -- Temporary file for gathering benchmarking results for each regexp engine. local result_file = 'benchmark.out' 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/benchmark/preload.lua b/test/benchmark/preload.lua index 1971ef77cc..a7b815ddf8 100644 --- a/test/benchmark/preload.lua +++ b/test/benchmark/preload.lua @@ -1,4 +1,4 @@ -- Modules loaded here will not be cleared and reloaded by Busted. -- Busted started doing this to help provide more isolation. See issue #62 -- for more information about this. -local helpers = require('test.functional.helpers') +local n = require('test.functional.testnvim') diff --git a/test/benchmark/screenpos_spec.lua b/test/benchmark/screenpos_spec.lua index 8a80712dfa..db8f918817 100644 --- a/test/benchmark/screenpos_spec.lua +++ b/test/benchmark/screenpos_spec.lua @@ -1,7 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) -local api = helpers.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local api = n.api + local function rand_utf8(count, seed) math.randomseed(seed) local symbols = { 'i', 'À', 'Ⱡ', '𐀀' } @@ -78,7 +80,7 @@ local N = 10000 local function benchmark(lines, expected_value) local lnum = #lines - local results = helpers.exec_lua( + local results = n.exec_lua( [==[ local N, lnum = ... @@ -99,7 +101,7 @@ local function benchmark(lines, expected_value) ) for _, value in ipairs(results[1]) do - helpers.eq(expected_value, value) + t.eq(expected_value, value) end local stats = results[2] table.sort(stats) @@ -119,7 +121,7 @@ end local function benchmarks(benchmark_results) describe('screenpos() perf', function() - before_each(helpers.clear) + before_each(n.clear) -- no breakindent for li, lines_type in ipairs(benchmark_lines) do @@ -134,7 +136,7 @@ local function benchmarks(benchmark_results) screen:attach() api.nvim_buf_set_lines(0, 0, 1, false, lines) -- for smaller screen expect (last line always different, first line same as others) - helpers.feed('G$') + n.feed('G$') screen:expect(result.screen) benchmark(lines, result.value) end) @@ -153,9 +155,9 @@ local function benchmarks(benchmark_results) local screen = Screen.new(width, height + 1) screen:attach() api.nvim_buf_set_lines(0, 0, 1, false, lines) - helpers.command('set breakindent') + n.command('set breakindent') -- for smaller screen expect (last line always different, first line same as others) - helpers.feed('G$') + n.feed('G$') screen:expect(result.screen) benchmark(lines, result.value) end) diff --git a/test/benchmark/treesitter_spec.lua b/test/benchmark/treesitter_spec.lua index 7c9906a7b2..b13b0fd9da 100644 --- a/test/benchmark/treesitter_spec.lua +++ b/test/benchmark/treesitter_spec.lua @@ -1,7 +1,7 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() -local clear = helpers.clear -local exec_lua = helpers.exec_lua +local clear = n.clear +local exec_lua = n.exec_lua describe('treesitter perf', function() setup(function() @@ -9,7 +9,7 @@ describe('treesitter perf', function() end) it('can handle large folds', function() - helpers.command 'edit ./src/nvim/eval.c' + n.command 'edit ./src/nvim/eval.c' exec_lua [[ local parser = vim.treesitter.get_parser(0, "c", {}) vim.treesitter.highlighter.new(parser) |