Permalink
Browse files

Run the garbage collector before each benchmark

This makes sure that garabage created by previous benchmarks don't
affect the current benchmark.
  • Loading branch information...
1 parent fa9f57a commit c868e5168030cca0a2584e39af35bdff70f8e3a3 @tibbe tibbe committed Feb 29, 2012
Showing with 3 additions and 0 deletions.
  1. +3 −0 Criterion.hs
View
@@ -62,6 +62,9 @@ runBenchmark env b = do
when (fromLJ cfgVerbosity cfg > Normal || estTime > 5) $
note "collecting %d samples, %d iterations each, in estimated %s\n"
sampleCount newIters (secs estTime)
+ -- Run the GC to make sure garabage created by previous benchmarks
+ -- don't affect this benchmark.
+ liftIO performGC
times <- liftIO . fmap (U.map ((/ newItersD) . subtract (envClockCost env))) .
U.replicateM sampleCount $ do
when (fromLJ cfgPerformGC cfg) $ performGC

0 comments on commit c868e51

Please sign in to comment.