2024-04-20 08:44:13 -07:00
|
|
|
" Also used by: test/functional/testnvim.lua
|
2019-05-18 00:50:44 -07:00
|
|
|
|
2019-01-16 13:20:38 -07:00
|
|
|
function! s:load_factor() abort
|
|
|
|
let timeout = 200
|
|
|
|
let times = []
|
|
|
|
|
|
|
|
for _ in range(5)
|
|
|
|
let g:val = 0
|
|
|
|
let start = reltime()
|
2019-08-13 23:59:06 -07:00
|
|
|
call timer_start(timeout, {-> nvim_set_var('val', 1)})
|
2019-01-16 13:20:38 -07:00
|
|
|
while 1
|
|
|
|
sleep 10m
|
|
|
|
if g:val == 1
|
|
|
|
let g:waited_in_ms = float2nr(reltimefloat(reltime(start)) * 1000)
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
endwhile
|
|
|
|
call insert(times, g:waited_in_ms, 0)
|
|
|
|
endfor
|
|
|
|
|
|
|
|
let longest = max(times)
|
|
|
|
let factor = (longest + 50.0) / timeout
|
|
|
|
|
|
|
|
return factor
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Compute load factor only once.
|
2019-05-18 00:50:44 -07:00
|
|
|
let g:test_load_factor = s:load_factor()
|
2019-01-16 13:20:38 -07:00
|
|
|
|
|
|
|
function! LoadAdjust(num) abort
|
2019-05-18 00:50:44 -07:00
|
|
|
return float2nr(ceil(a:num * g:test_load_factor))
|
2019-01-16 13:20:38 -07:00
|
|
|
endfunction
|