Commits

Anonymous committed 51caa27

Stopped results being retained until the end if you do not want to plot the graphs with a shared axis

  • Participants
  • Parent commits 90b1e8b

Comments (0)

Files changed (1)

 import Criterion.Plot (plotWith, plotKDE, plotTiming)
 import Criterion.Types (Benchmarkable(..), Benchmark(..), bench, bgroup)
 import Data.Array.Vector ((:*:)(..), lengthU, mapU, foldlU)
-import Data.Maybe (mapMaybe)
+import Data.Maybe (fromMaybe, mapMaybe)
 import Data.Monoid (getLast)
 import Statistics.Function (createIO)
 import Statistics.KernelDensity (epanechnikovPDF)
               -> Benchmark
               -> IO ()
 runAndAnalyse p cfg env
-  = (case getLast $ cfgPlotSameAxis cfg of
-       Just True -> plotAll cfg
-       _ -> mapM_ (uncurry $ plotOne cfg)
+  = (if plotSame
+       then plotAll cfg
+       else const $ return ()
     ) <=< go ""
   where go pfx (Benchmark desc b)
             | p desc'   = do note cfg "\nbenchmarking %s\n" desc'
                              x <- runAndAnalyseOne cfg env desc' b
-                             return [(desc', x)]
+                             if plotSame
+                               then return [(desc', x)]
+                               else do plotOne cfg desc' x
+                                       return []
             | otherwise = return []
             where desc' = prefix pfx desc
         go pfx (BenchGroup desc bs) = liftM concat $ mapM (go (prefix pfx desc)) bs
         prefix ""  desc = desc
         prefix pfx desc = pfx ++ '/' : desc
+
+        plotSame = fromMaybe False $ getLast $ cfgPlotSameAxis cfg