robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
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 () 9before_each ( clear ) 10 11local trials =20000 12 13it ( 'vim.o scalar (number)' , function () 14bench ( [[vim.o.scrolloff = i % 10]] , { n =trials , label ='vim.o.scrolloff = i % 10' } ) 15end ) 16 17it ( 'vim.o scalar (boolean)' , function () 18bench ( [[vim.o.wrap = (i % 2 == 0)]] , { n =trials , label ='vim.o.wrap = (i % 2 == 0)' } ) 19end ) 20 21it ( 'vim.o scalar (string)' , function () 22-- makeprg has a trivial did_set handler, so this isolates the set path itself. 23bench ( [[vim.o.makeprg = 'make']] , { n =trials , label ="vim.o.makeprg = 'make'" } ) 24end ) 25 26it ( 'vim.opt array via table' , function () 27bench ( [[vim.opt.wildignore = { '*.o', '*.a', '*.so' }]] , { 28n =trials , 29label ="vim.opt.wildignore = {'*.o','*.a','*.so'}" , 30} ) 31end ) 32 33it ( 'vim.opt map via table' , function () 34bench ( [[vim.opt.listchars = { eol = '~', space = '.', tab = '> ' }]] , { 35n =trials , 36label ="vim.opt.listchars = { eol='~', space='.', tab='> ' }" , 37} ) 38end ) 39 40it ( 'vim.opt:append (operation)' , function () 41bench ( 42[[ 43vim.o.wildignore = '' 44vim.opt.wildignore:append({ '*.tmp', '*.bak' }) 45]] , 46{ n =trials , label ='vim.opt.wildignore:append(...)' } 47) 48end ) 49 50it ( 'nvim_set_option_value with table (direct API)' , function () 51bench ( [[vim.api.nvim_set_option_value('listchars', { eol = '~', space = '.' }, {})]] , { 52n =trials , 53label ='nvim_set_option_value(listchars, {..})' , 54} ) 55end ) 56end )