robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2 3local describe , it =t . describe , t . it 4describe ( 'vim.trim()' , function () 5local strings ={ 6[ '10000 whitespace characters' ] =string . rep ( ' ' , 10000 ), 7[ '10000 whitespace characters and one non-whitespace at the end' ] =string . rep ( ' ' , 10000 ) 8.. '0' , 9[ '10000 whitespace characters and one non-whitespace at the start' ] ='0' 10.. string . rep ( ' ' , 10000 ), 11[ '10000 non-whitespace characters' ] =string . rep ( '0' , 10000 ), 12[ '10000 whitespace and one non-whitespace in the middle' ] =string . rep ( ' ' , 5000 ) 13.. 'a' 14.. string . rep ( ' ' , 5000 ), 15[ '10000 whitespace characters surrounded by non-whitespace' ] ='0' 16.. string . rep ( ' ' , 10000 ) 17.. '0' , 18[ '10000 non-whitespace characters surrounded by whitespace' ] =' ' 19.. string . rep ( '0' , 10000 ) 20.. ' ' , 21} 22 23--- @type string[] 24local string_names =vim . tbl_keys ( strings ) 25table . sort ( string_names ) 26 27for _ , name in ipairs ( string_names ) do 28it ( name , function () 29t . bench ( function () 30vim . trim ( strings [ name ]) 31end , { n =100 , label =name } ) 32end ) 33end 34end )