perf-0.10.3: Low-level run time measurement.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Perf.Types

Description

Abstract types of performance measurement.

Synopsis

Documentation

data Measure m t Source #

Abstraction of a performance measurement within a monadic context.

  • measure applies a function to a value, returning a tuple of the performance measure, and the computation result.
  • measureM evaluates a monadic value and returns a performance-result tuple.

Constructors

Measure 

Fields

  • measure :: forall a b. (a -> b) -> a -> m (t, b)
     
  • measureM :: forall a. m a -> m (t, a)
     

Instances

Instances details
Applicative m => Applicative (Measure m) Source #

An inefficient application that runs the inner action twice.

Instance details

Defined in Perf.Types

Methods

pure :: a -> Measure m a #

(<*>) :: Measure m (a -> b) -> Measure m a -> Measure m b #

liftA2 :: (a -> b -> c) -> Measure m a -> Measure m b -> Measure m c #

(*>) :: Measure m a -> Measure m b -> Measure m b #

(<*) :: Measure m a -> Measure m b -> Measure m a #

Functor m => Functor (Measure m) Source # 
Instance details

Defined in Perf.Types

Methods

fmap :: (a -> b) -> Measure m a -> Measure m b #

(<$) :: a -> Measure m b -> Measure m a #

repeated :: Applicative m => Int -> Measure m t -> Measure m [t] Source #

Convert a Measure into a multi measure.

data StepMeasure m t Source #

Abstraction of a performance measurement with a pre and a post step wrapping the computation.

Constructors

forall i. StepMeasure 

Fields

Instances

Instances details
Applicative m => Applicative (StepMeasure m) Source # 
Instance details

Defined in Perf.Types

Methods

pure :: a -> StepMeasure m a #

(<*>) :: StepMeasure m (a -> b) -> StepMeasure m a -> StepMeasure m b #

liftA2 :: (a -> b -> c) -> StepMeasure m a -> StepMeasure m b -> StepMeasure m c #

(*>) :: StepMeasure m a -> StepMeasure m b -> StepMeasure m b #

(<*) :: StepMeasure m a -> StepMeasure m b -> StepMeasure m a #

Functor m => Functor (StepMeasure m) Source # 
Instance details

Defined in Perf.Types

Methods

fmap :: (a -> b) -> StepMeasure m a -> StepMeasure m b #

(<$) :: a -> StepMeasure m b -> StepMeasure m a #

toMeasure :: Monad m => StepMeasure m t -> Measure m t Source #

Convert a StepMeasure into a Measure

toMeasureN :: Monad m => Int -> StepMeasure m t -> Measure m [t] Source #

Convert a StepMeasure into a Measure running the computation multiple times.

step :: Monad m => m i -> (i -> m t) -> (a -> b) -> a -> m (t, b) Source #

A single step measurement.

stepM :: Monad m => m i -> (i -> m t) -> m a -> m (t, a) Source #

A single step measurement.

multi :: Monad m => ((a -> b) -> a -> m (t, b)) -> Int -> (a -> b) -> a -> m ([t], b) Source #

Multiple measurement

multiM :: Monad m => (m a -> m (t, a)) -> Int -> m a -> m ([t], a) Source #

Multiple measurements

function application

fap :: (MonadIO m, Semigroup t) => Text -> (a -> b) -> a -> PerfT m t b Source #

Lift an application to a PerfT m, providing a label and a Measure.

Measurements with the same label will be mappended

afap :: (NFData a, MonadIO m, Semigroup t) => Text -> (a -> b) -> a -> PerfT m t b Source #

Lift an application to a PerfT m, forcing the argument.

ffap :: (NFData a, NFData b, MonadIO m, Semigroup t) => Text -> (a -> b) -> a -> PerfT m t b Source #

Lift an application to a PerfT m, forcing argument and result.

fan :: (MonadIO m, Num t) => Text -> (a -> b) -> a -> PerfT m t b Source #

Lift a number to a PerfT m, providing a label, function, and input.

Measurements with the same label will be added

fam :: (MonadIO m, Semigroup t) => Text -> m a -> PerfT m t a Source #

Lift a monadic value to a PerfT m, providing a label and a Measure.

Measurements with the same label will be added

(|$|) :: Semigroup t => (a -> b) -> a -> PerfT IO t b Source #

lift a pure, unnamed function application to PerfT

($|) :: Semigroup t => IO a -> PerfT IO t a Source #

lift a monadic, unnamed function application to PerfT

(|+|) :: Num t => (a -> b) -> a -> PerfT IO t b Source #

lift an unnamed numeric measure to PerfT

PerfT monad

newtype PerfT m t a Source #

Performance measurement transformer storing a Measure and a map of named results.

Constructors

PerfT 

Fields

Instances

Instances details
MonadIO m => MonadIO (PerfT m t) Source # 
Instance details

Defined in Perf.Types

Methods

liftIO :: IO a -> PerfT m t a #

Monad m => Applicative (PerfT m t) Source # 
Instance details

Defined in Perf.Types

Methods

pure :: a -> PerfT m t a #

(<*>) :: PerfT m t (a -> b) -> PerfT m t a -> PerfT m t b #

liftA2 :: (a -> b -> c) -> PerfT m t a -> PerfT m t b -> PerfT m t c #

(*>) :: PerfT m t a -> PerfT m t b -> PerfT m t b #

(<*) :: PerfT m t a -> PerfT m t b -> PerfT m t a #

Functor m => Functor (PerfT m t) Source # 
Instance details

Defined in Perf.Types

Methods

fmap :: (a -> b) -> PerfT m t a -> PerfT m t b #

(<$) :: a -> PerfT m t b -> PerfT m t a #

Monad m => Monad (PerfT m t) Source # 
Instance details

Defined in Perf.Types

Methods

(>>=) :: PerfT m t a -> (a -> PerfT m t b) -> PerfT m t b #

(>>) :: PerfT m t a -> PerfT m t b -> PerfT m t b #

return :: a -> PerfT m t a #

type Perf t a = PerfT Identity t a Source #

The transformer over Identity

runPerfT :: Functor m => Measure m t -> PerfT m t a -> m (a, Map Text t) Source #

Run the performance measure, returning (computational result, measurement).

evalPerfT :: Monad m => Measure m t -> PerfT m t a -> m a Source #

Consume the PerfT layer and return the original monadic result. Fingers crossed, PerfT structure should be completely compiled away.

execPerfT :: Monad m => Measure m t -> PerfT m t a -> m (Map Text t) Source #

Consume a PerfT layer and return the measurement.

outer :: (MonadIO m, Semigroup s) => Text -> Measure m s -> Measure m t -> PerfT m t a -> m (a, (Map Text s, Map Text t)) Source #

run a PerfT and also calculate performance over the entire computation

slop :: (MonadIO m, Num t, Semigroup t) => Text -> Measure m t -> PerfT m t a -> m (a, Map Text t) Source #

run a PerfT and calculate excess performance over the entire computation

slops :: (MonadIO m, Num t, Semigroup t) => Int -> Measure m t -> PerfT m [t] a -> m (a, (Map Text t, Map Text [t])) Source #

run a multi PerfT and calculate excess performance over the entire computation