From: Michael Hollins Date: 2007-06-29T10:40:08+09:00 Subject: Re: when to Run the garbage collector? Sylvain Joyeux wrote: > It may be difficult to benchmark (or profile for that matter) code under > GC: if the GC runs, you can get more than 200ms accounted to whichever > method was being run. > > If you can afford the memory allocation of your benchmarked code, try > GC.start ; GC.disable before starting the bench. Given that the GC runs during real world operation, and that benchmarks are generally about determining whether some code will perform acceptebley in a real situation, I'm not sure the above is great advice. Seems to me it would be better to write benchmarks that run for an amount of time that is sufficient to ensure that the overhead of GC is consistent between runs of the benchmark. For example, don't write a benchmark that takes 0.001 seconds. Write one that takes 30 seconds, or whatever. I'm not experienced enough with ruby yet, to know what a sensible duration is. cheers, mick