module Criterion.Analysis.Types
(
Outliers (..)
, OutlierEffect(..)
, OutlierVariance(..)
, SampleAnalysis(..)
) where
import Control.DeepSeq (NFData(rnf))
import Data.Binary (Binary)
import Data.Data (Data, Typeable)
import Data.Int (Int64)
import Data.Monoid (Monoid(..))
import GHC.Generics (Generic)
import qualified Statistics.Resampling.Bootstrap as B
data Outliers = Outliers {
samplesSeen :: !Int64
, lowSevere :: !Int64
, lowMild :: !Int64
, highMild :: !Int64
, highSevere :: !Int64
} deriving (Eq, Read, Show, Typeable, Data, Generic)
instance Binary Outliers
instance NFData Outliers
data OutlierEffect = Unaffected
| Slight
| Moderate
| Severe
deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)
instance Binary OutlierEffect
instance NFData OutlierEffect
instance Monoid Outliers where
mempty = Outliers 0 0 0 0 0
mappend = addOutliers
addOutliers :: Outliers -> Outliers -> Outliers
addOutliers (Outliers s a b c d) (Outliers t w x y z) =
Outliers (s+t) (a+w) (b+x) (c+y) (d+z)
data OutlierVariance = OutlierVariance {
ovEffect :: OutlierEffect
, ovDesc :: String
, ovFraction :: Double
} deriving (Eq, Read, Show, Typeable, Data, Generic)
instance Binary OutlierVariance
instance NFData OutlierVariance where
rnf OutlierVariance{..} = rnf ovEffect `seq` rnf ovDesc `seq` rnf ovFraction
data SampleAnalysis = SampleAnalysis {
anMean :: B.Estimate
, anStdDev :: B.Estimate
, anOutlierVar :: OutlierVariance
} deriving (Eq, Read, Show, Typeable, Data, Generic)
instance Binary SampleAnalysis
instance NFData SampleAnalysis where
rnf SampleAnalysis{..} =
rnf anMean `seq` rnf anStdDev `seq` rnf anOutlierVar