    {-# LANGUAGE RecordWildCards #-}
    -- |
    -- Module      : Criterion
    -- Copyright   : (c) 2009-2014 Bryan O'Sullivan
    --
    -- License     : BSD-style
    -- Maintainer  : bos@serpentine.com
    -- Stability   : experimental
    -- Portability : GHC
    --
    -- Core benchmarking code.

    module Criterion
        (
        -- * Benchmarkable code
          Benchmarkable
        -- * Creating a benchmark suite
        , Benchmark
        , env
        , envWithCleanup
        , perBatchEnv
        , perBatchEnvWithCleanup
        , perRunEnv
        , perRunEnvWithCleanup
        , toBenchmarkable
        , bench
        , bgroup
        -- ** Running a benchmark
        , nf
        , whnf
        , nfIO
        , whnfIO
        , nfAppIO
        , whnfAppIO
        -- * For interactive use
        , benchmark
        , benchmarkWith
        , benchmark'
        , benchmarkWith'
        ) where

    import Control.Monad (void)
    import Criterion.IO.Printf (note)
    import Criterion.Internal (runAndAnalyseOne)
    import Criterion.Main.Options (defaultConfig)
    import Criterion.Measurement (initializeTime)
    import Criterion.Monad (withConfig)
    import Criterion.Types

    -- | Run a benchmark interactively, and analyse its performance.
    benchmark :: Benchmarkable -> IO ()
    benchmark :: Benchmarkable -> IO ()
    benchmark Benchmarkable
    bm = IO Report -> IO ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (IO Report -> IO ()) -> IO Report -> IO ()
    forall a b. (a -> b) -> a -> b
    $ Benchmarkable -> IO Report
    benchmark' Benchmarkable
    bm

    -- | Run a benchmark interactively, analyse its performance, and
    -- return the analysis.
    benchmark' :: Benchmarkable -> IO Report
    benchmark' :: Benchmarkable -> IO Report
    benchmark' = Config -> Benchmarkable -> IO Report
    benchmarkWith' Config
    defaultConfig

    -- | Run a benchmark interactively, and analyse its performance.
    benchmarkWith :: Config -> Benchmarkable -> IO ()
    benchmarkWith :: Config -> Benchmarkable -> IO ()
    benchmarkWith Config
    cfg Benchmarkable
    bm = IO Report -> IO ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (IO Report -> IO ()) -> IO Report -> IO ()
    forall a b. (a -> b) -> a -> b
    $ Config -> Benchmarkable -> IO Report
    benchmarkWith' Config
    cfg Benchmarkable
    bm

    -- | Run a benchmark interactively, analyse its performance, and
    -- return the analysis.
    benchmarkWith' :: Config -> Benchmarkable -> IO Report
    benchmarkWith' :: Config -> Benchmarkable -> IO Report
    benchmarkWith' Config
    cfg Benchmarkable
    bm = do
      IO ()
    initializeTime
      Config -> Criterion Report -> IO Report
    forall a. Config -> Criterion a -> IO a
    withConfig Config
    cfg (Criterion Report -> IO Report) -> Criterion Report -> IO Report
    forall a b. (a -> b) -> a -> b
    $ do
        _ <- String -> Criterion (ZonkAny 0)
    forall r. CritHPrintfType r => String -> r
    note String
    "benchmarking...\n"
        Analysed rpt <- runAndAnalyseOne 0 "function" bm
        return rpt