weigh-0.0.1: 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.

data Weight Source

How much a computation weighed in at.

Simple combinators

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

Weigh an IO action.

Implemented in terms of validateAction.

func :: NFData a => String -> (b -> 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.

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.