make draw-mem test more reliable

This commit is contained in:
Matthew Flatt 2012-01-09 16:07:20 -07:00
parent 23010fc495
commit 7b4fd9b275

View File

@ -4,8 +4,10 @@
(define my-ns-channel (make-parameter #f))
(define N 20)
(define-values (incs m ns)
(for/fold ([incs 0] [max-mem 0] [ns #f]) ([i 10])
(for/fold ([incs 0] [max-mem 0] [accum #f]) ([i N])
(define ns (make-base-namespace))
(parameterize ([current-namespace ns]
[my-ns-channel ns])
@ -15,10 +17,10 @@
(collect-garbage)
(let ([m (current-memory-use)])
(printf "~s\n" m)
(if (m . > . max-mem)
(values (add1 incs) m 'ns)
(values incs max-mem 'ns)))))
(if (m . > . (* 1.1 max-mem))
(values (add1 incs) m accum)
(values incs max-mem accum)))))
(unless (incs . < . 5)
(unless (incs . < . (/ N 3))
(error "multiple `racket/draw' instantiations seem to accumulate memory"))