weigh-0.0.2: Measure allocations of a Haskell functions/values

Safe HaskellNone
LanguageHaskell2010

Weigh

Contents

Description

Framework for seeing how much a function allocates.

Synopsis

Main entry point.

mainWith :: Weigh a -> IO () Source #

Just run the measuring and print a report.

Types

data Weigh a Source #

Weigh specification monad.

Instances

Monad Weigh Source # 

Methods

(>>=) :: Weigh a -> (a -> Weigh b) -> Weigh b #

(>>) :: Weigh a -> Weigh b -> Weigh b #

return :: a -> Weigh a #

fail :: String -> Weigh a #

Functor Weigh Source # 

Methods

fmap :: (a -> b) -> Weigh a -> Weigh b #

(<$) :: a -> Weigh b -> Weigh a #

Applicative Weigh Source # 

Methods

pure :: a -> Weigh a #

(<*>) :: Weigh (a -> b) -> Weigh a -> Weigh b #

(*>) :: Weigh a -> Weigh b -> Weigh b #

(<*) :: Weigh a -> Weigh b -> Weigh a #

data Weight Source #

How much a computation weighed in at.

Simple combinators

func :: NFData a => String -> (b -> a) -> b -> Weigh () Source #

Weigh a function applied to an argument.

Implemented in terms of validateFunc.

io :: NFData a => String -> (b -> IO a) -> b -> Weigh () Source #

Weigh a function applied to an argument.

Implemented in terms of validateFunc.

value :: NFData a => String -> a -> Weigh () Source #

Weigh a value.

Implemented in terms of action.

action :: NFData a => String -> IO a -> Weigh () Source #

Weigh an IO action.

Implemented in terms of validateAction.

Validating combinators

validateAction :: NFData a => String -> (b -> IO a) -> b -> (Weight -> Maybe String) -> Weigh () Source #

Weigh an IO action, validating the result.

validateFunc :: NFData a => String -> (b -> a) -> b -> (Weight -> Maybe String) -> Weigh () Source #

Weigh a function, validating the result

Validators

maxAllocs :: Int64 -> Weight -> Maybe String Source #

Make a validator that set sthe maximum allocations.

Handy utilities

commas :: (Num a, Integral a, Show a) => a -> String Source #

Formatting an integral number to 1,000,000, etc.