Bryan O'Sullivan avatar Bryan O'Sullivan committed 99df50b

Rename ConfigM to Criterion.

Comments (0)

Files changed (6)

 import Criterion.Environment (Environment(..))
 import Criterion.IO (note, prolix, summary)
 import Criterion.Measurement (getTime, runForAtLeast, secs, time_)
-import Criterion.Monad (ConfigM, getConfig, getConfigItem)
+import Criterion.Monad (Criterion, getConfig, getConfigItem)
 import Criterion.Plot (plotWith, plotKDE, plotTiming)
 import Criterion.Types (Benchmarkable(..), Benchmark(..), Pure,
                         bench, bgroup, nf, whnf)
 
 -- | Run a single benchmark, and return timings measured when
 -- executing it.
-runBenchmark :: Benchmarkable b => Environment -> b -> ConfigM Sample
+runBenchmark :: Benchmarkable b => Environment -> b -> Criterion Sample
 runBenchmark env b = do
   liftIO $ runForAtLeast 0.1 10000 (`replicateM_` getTime)
   let minTime = envClockResolution env * 1000
 
 -- | Run a single benchmark and analyse its performance.
 runAndAnalyseOne :: Benchmarkable b => Environment -> String -> b
-                 -> ConfigM Sample
+                 -> Criterion Sample
 runAndAnalyseOne env _desc b = do
   times <- runBenchmark env b
   let numSamples = lengthU times
   note "variance introduced by outliers: %.3f%%\n" (v * 100)
   note "variance is %s by outliers\n" wibble
   return times
-  where bs :: String -> Estimate -> ConfigM ()
+  where bs :: String -> Estimate -> Criterion ()
         bs d e = do note "%s: %s, lb %s, ub %s, ci %.3f\n" d
                       (secs $ estPoint e)
                       (secs $ estLowerBound e) (secs $ estUpperBound e)
                       (estPoint e)
                       (estLowerBound e) (estUpperBound e)
 
-plotAll :: [(String, Sample)] -> ConfigM ()
+plotAll :: [(String, Sample)] -> Criterion ()
 plotAll descTimes = forM_ descTimes $ \(desc,times) -> do
   plotWith Timing $ \o -> plotTiming o desc times
   plotWith KernelDensity $ \o -> uncurry (plotKDE o desc extremes)
                                   -- name.
               -> Environment
               -> Benchmark
-              -> ConfigM ()
+              -> Criterion ()
 runAndAnalyse p env = plotAll <=< go ""
   where go pfx (Benchmark desc b)
             | p desc'   = do note "\nbenchmarking %s\n" desc'

Criterion/Analysis.hs

 import Control.Monad (when)
 import Criterion.IO (note)
 import Criterion.Measurement (secs)
-import Criterion.Monad (ConfigM)
+import Criterion.Monad (Criterion)
 import Data.Array.Vector (foldlU)
 import Data.Int (Int64)
 import Data.Monoid (Monoid(..))
 analyseMean :: Sample
             -> Int              -- ^ Number of iterations used to
                                 -- compute the sample.
-            -> ConfigM Double
+            -> Criterion Double
 analyseMean a iters = do
   let µ = mean a
   note "mean is %s (%d iterations)\n" (secs µ) iters
   return µ
 
 -- | Display a report of the 'Outliers' present in a 'Sample'.
-noteOutliers :: Outliers -> ConfigM ()
+noteOutliers :: Outliers -> Criterion ()
 noteOutliers o = do
   let frac n = (100::Double) * fromIntegral n / fromIntegral (samplesSeen o)
-      check :: Int64 -> Double -> String -> ConfigM ()
+      check :: Int64 -> Double -> String -> Criterion ()
       check k t d = when (frac k > t) $
                     note "  %d (%.1g%%) %s\n" k (frac k) d
       outCount = countOutliers o

Criterion/Environment.hs

 import Criterion.Analysis (analyseMean)
 import Criterion.IO (note)
 import Criterion.Measurement (getTime, runForAtLeast, time_)
-import Criterion.Monad (ConfigM)
+import Criterion.Monad (Criterion)
 import Data.Array.Vector
 import Data.Typeable (Typeable)
 import Statistics.Function (createIO)
     } deriving (Eq, Read, Show, Typeable)
 
 -- | Measure the execution environment.
-measureEnvironment :: ConfigM Environment
+measureEnvironment :: Criterion Environment
 measureEnvironment = do
   note "warming up\n"
   (_ :*: seed :*: _) <- liftIO $ runForAtLeast 0.1 10000 resolution
 import Control.Monad (when)
 import Control.Monad.Trans (liftIO)
 import Criterion.Config (Config, Verbosity(..), cfgSummaryFile, cfgVerbosity, fromLJ)
-import Criterion.Monad (ConfigM, getConfig, getConfigItem)
+import Criterion.Monad (Criterion, getConfig, getConfigItem)
 import Data.Monoid (getLast)
 import System.IO (Handle, stderr, stdout)
 import qualified Text.Printf (HPrintfType, hPrintf)
   chPrintfImpl :: (Config -> Bool) -> PrintfCont -> a
 
 
-instance CritHPrintfType (ConfigM a) where
+instance CritHPrintfType (Criterion a) where
   chPrintfImpl check (PrintfCont final _)
     = do x <- getConfig
          when (check x) (liftIO final)
 printError = chPrintf (const True) stderr
 
 -- | Add to summary CSV (if applicable)
-summary :: String -> ConfigM ()
+summary :: String -> Criterion ()
 summary msg
   = do sumOpt <- getConfigItem (getLast . cfgSummaryFile)
        case sumOpt of

Criterion/Monad.hs

 -- The environment in which most criterion code executes.
 module Criterion.Monad
     (
-      ConfigM
+      Criterion
     , getConfig
     , getConfigItem
     , withConfig
 import Criterion.Config (Config)
 
 -- | The monad in which most criterion code executes.
-newtype ConfigM a = ConfigM {
-      runConfigM :: ReaderT Config IO a
+newtype Criterion a = Criterion {
+      runCriterion :: ReaderT Config IO a
     } deriving (Functor, Monad, MonadReader Config, MonadIO)
 
-getConfig :: ConfigM Config
+getConfig :: Criterion Config
 getConfig = ask
 
-getConfigItem :: (Config -> a) -> ConfigM a
+getConfigItem :: (Config -> a) -> Criterion a
 getConfigItem f = f `fmap` getConfig
 
-withConfig :: Config -> ConfigM a -> IO a
-withConfig = flip (runReaderT . runConfigM)
+withConfig :: Config -> Criterion a -> IO a
+withConfig = flip (runReaderT . runCriterion)

Criterion/Plot.hs

 
 import Control.Monad.Trans (liftIO)
 import Criterion.Config
-import Criterion.Monad (ConfigM, getConfigItem)
+import Criterion.Monad (Criterion, getConfigItem)
 import Data.Array.Vector
 import Data.Char (isSpace, toLower)
 import Data.Foldable (forM_)
 import Criterion.IO (printError)
 #endif
 
-plotWith :: Plot -> (PlotOutput -> IO ()) -> ConfigM ()
+plotWith :: Plot -> (PlotOutput -> IO ()) -> Criterion ()
 plotWith p plot = getConfigItem (M.lookup p . cfgPlot)
                     >>= maybe (return ()) (liftIO . flip forM_ plot)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.