[racket] interactive.rkt

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Oct 14 08:08:24 EDT 2010

At Thu, 14 Oct 2010 08:01:50 -0400, Neil Van Dyke wrote:
> Matthew Flatt wrote at 10/14/2010 07:53 AM:
> > A third `(collect-garbage)' offers diminishing returns, but it might do 
> something and it doesn't particularly hurt.
> 
> Question...  For performance testing, I often code something like this:
> 
> 1. Try to collect all the garbage I can.
> 
> 2. Start the clock.
> 
> 3. Run N iterations of the code in question.
> 
> 4. Check the clock.
> 
> 5. Do a final garbage collection to make sure I feel any remaining pain 
> from garbage I've generated.
> 
> 6. Check the clock again.
> 
> For steps #1 and #5, is calling "collect-garbage" three times the best I 
> can do?

I suppose that you could use `(current-memory-use)' and try to detect
when memory use stops going down. Just running `(collect-garbage)' a
couple of times should be good enough, though. You might still be
misled in some way by using only three `(collect-garbage)' calls, but
other things like OS scheduling and paging are equally likely to
mislead at that level.



Posted on the users mailing list.