module BuildBox.Benchmark.Base
( Benchmark(..)
, Timing(..)
, BenchRunResult(..)
, BenchResult(..))
where
import BuildBox.Build
import BuildBox.Pretty
import Control.Monad
data Benchmark
= Benchmark
{
benchmarkName :: String
, benchmarkSetup :: Build ()
, benchmarkCommand :: Build (Maybe Timing)
, benchmarkCheck :: Build ()
}
data Timing
= Timing
{ timingElapsed :: Maybe Float
, timingCpu :: Maybe Float
, timingSys :: Maybe Float }
deriving (Eq, Read, Show)
data BenchRunResult
= BenchRunResult
{
benchRunResultElapsed :: Float
, benchRunResultKernel :: Maybe Timing }
deriving (Show, Read)
instance Pretty BenchRunResult where
ppr result
= hang (ppr "BenchRunResult") 2 $ vcat
[ ppr "elapsed: " <> (ppr $ benchRunResultElapsed result)
, maybe empty (\r -> ppr "k.elapsed: " <> ppr r)
$ join $ liftM timingElapsed $ benchRunResultKernel result
, maybe empty (\r -> ppr "k.cpu: " <> ppr r)
$ join $ liftM timingCpu $ benchRunResultKernel result
, maybe empty (\r -> ppr "k.system: " <> ppr r)
$ join $ liftM timingSys $ benchRunResultKernel result ]
data BenchResult
= BenchResult
{ benchResultName :: String
, benchResultRuns :: [BenchRunResult] }
deriving (Show, Read)
instance Pretty BenchResult where
ppr result
= hang (ppr "BenchResult") 2 $ vcat
[ ppr $ benchResultName result
, vcat $ map ppr $ benchResultRuns result ]