1
0
forked from aniani/vim

patch 8.1.1031: memory usage test may still fail

Problem:    Memory usage test may still fail.
Solution:   Drop the unused min value. (Christian Brabandt)
This commit is contained in:
Bram Moolenaar
2019-03-21 21:16:36 +01:00
parent 0398e00a1b
commit f7e47af776
2 changed files with 13 additions and 9 deletions

View File

@@ -36,15 +36,12 @@ func s:monitor_memory_usage(pid) abort
let proc = {} let proc = {}
let proc.pid = a:pid let proc.pid = a:pid
let proc.hist = [] let proc.hist = []
let proc.min = 0
let proc.max = 0 let proc.max = 0
func proc.op() abort func proc.op() abort
" Check the last 200ms. " Check the last 200ms.
let val = s:memory_usage(self.pid) let val = s:memory_usage(self.pid)
if self.min > val if self.max < val
let self.min = val
elseif self.max < val
let self.max = val let self.max = val
endif endif
call add(self.hist, val) call add(self.hist, val)
@@ -56,7 +53,7 @@ func s:monitor_memory_usage(pid) abort
endfunc endfunc
call WaitFor({-> proc.op()}, 10000) call WaitFor({-> proc.op()}, 10000)
return {'last': get(proc.hist, -1), 'min': proc.min, 'max': proc.max} return {'last': get(proc.hist, -1), 'max': proc.max}
endfunc endfunc
let s:term_vim = {} let s:term_vim = {}
@@ -101,8 +98,11 @@ func Test_memory_func_capture_vargs()
" Estimate the limit of max usage as 2x initial usage. " Estimate the limit of max usage as 2x initial usage.
call assert_inrange(before, 2 * before, after.max) call assert_inrange(before, 2 * before, after.max)
" In this case, garbase collecting is not needed. " In this case, garbage collecting is not needed. The value might fluctuate
call assert_equal(after.last, after.max) " a bit, allow for 3% tolerance.
let lower = after.last * 97 / 100
let upper = after.last * 103 / 100
call assert_inrange(lower, upper, after.max)
call vim.stop() call vim.stop()
call delete(testfile) call delete(testfile)
@@ -137,9 +137,11 @@ func Test_memory_func_capture_lvars()
let last = s:monitor_memory_usage(vim.pid).last let last = s:monitor_memory_usage(vim.pid).last
endfor endfor
" The usage may be a bit less than the last value " The usage may be a bit less than the last value, use 80%.
" Allow for 1% tolerance at the upper limit.
let lower = before * 8 / 10 let lower = before * 8 / 10
call assert_inrange(lower, after.max + (after.last - before), last) let upper = (after.max + (after.last - before)) * 101 / 100
call assert_inrange(lower, upper, last)
call vim.stop() call vim.stop()
call delete(testfile) call delete(testfile)

View File

@@ -779,6 +779,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1031,
/**/ /**/
1030, 1030,
/**/ /**/