{-# LANGUAGE RecordWildCards #-}
module Criterion
(
Benchmarkable
, Benchmark
, env
, envWithCleanup
, perBatchEnv
, perBatchEnvWithCleanup
, perRunEnv
, perRunEnvWithCleanup
, toBenchmarkable
, bench
, bgroup
, nf
, whnf
, nfIO
, whnfIO
, nfAppIO
, whnfAppIO
, 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
benchmark :: Benchmarkable -> IO ()
benchmark bm = void $ benchmark' bm
benchmark' :: Benchmarkable -> IO Report
benchmark' = benchmarkWith' defaultConfig
benchmarkWith :: Config -> Benchmarkable -> IO ()
benchmarkWith cfg bm = void $ benchmarkWith' cfg bm
benchmarkWith' :: Config -> Benchmarkable -> IO Report
benchmarkWith' cfg bm = do
initializeTime
withConfig cfg $ do
_ <- note "benchmarking...\n"
Analysed rpt <- runAndAnalyseOne 0 "function" bm
return rpt