robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.6 KiB56 linesraw
1local n = require('test.functional.testnvim')()
2local t = require('test.testutil')
3
4local describe, it, before_each = t.describe, t.it, t.before_each
5local clear = n.clear
6local bench = n.bench
7
8describe('option set perf', function()
9  before_each(clear)
10
11  local trials = 20000
12
13  it('vim.o scalar (number)', function()
14    bench([[vim.o.scrolloff = i % 10]], { n = trials, label = 'vim.o.scrolloff = i % 10' })
15  end)
16
17  it('vim.o scalar (boolean)', function()
18    bench([[vim.o.wrap = (i % 2 == 0)]], { n = trials, label = 'vim.o.wrap = (i % 2 == 0)' })
19  end)
20
21  it('vim.o scalar (string)', function()
22    -- makeprg has a trivial did_set handler, so this isolates the set path itself.
23    bench([[vim.o.makeprg = 'make']], { n = trials, label = "vim.o.makeprg = 'make'" })
24  end)
25
26  it('vim.opt array via table', function()
27    bench([[vim.opt.wildignore = { '*.o', '*.a', '*.so' }]], {
28      n = trials,
29      label = "vim.opt.wildignore = {'*.o','*.a','*.so'}",
30    })
31  end)
32
33  it('vim.opt map via table', function()
34    bench([[vim.opt.listchars = { eol = '~', space = '.', tab = '> ' }]], {
35      n = trials,
36      label = "vim.opt.listchars = { eol='~', space='.', tab='> ' }",
37    })
38  end)
39
40  it('vim.opt:append (operation)', function()
41    bench(
42      [[
43      vim.o.wildignore = ''
44      vim.opt.wildignore:append({ '*.tmp', '*.bak' })
45    ]],
46      { n = trials, label = 'vim.opt.wildignore:append(...)' }
47    )
48  end)
49
50  it('nvim_set_option_value with table (direct API)', function()
51    bench([[vim.api.nvim_set_option_value('listchars', { eol = '~', space = '.' }, {})]], {
52      n = trials,
53      label = 'nvim_set_option_value(listchars, {..})',
54    })
55  end)
56end)