Safe Haskell | None |
---|---|
Language | Haskell2010 |
Framework for seeing how much a function allocates.
WARNING: weigh is incompatible with profiling. It reports much more allocations with profiling turned on.
Example:
import Weigh main = mainWith (do func "integers count 0" count 0 func "integers count 1" count 1 func "integers count 2" count 2 func "integers count 3" count 3 func "integers count 10" count 10 func "integers count 100" count 100) where count :: Integer -> () count 0 = () count a = count (a - 1)
Use wgroup
to group sets of tests.
- mainWith :: Weigh a -> IO ()
- weighResults :: Weigh a -> IO ([Grouped (Weight, Maybe String)], Config)
- setColumns :: [Column] -> Weigh ()
- data Column
- setFormat :: Format -> Weigh ()
- data Format
- setConfig :: Config -> Weigh ()
- data Config = Config {
- configColumns :: [Column]
- configPrefix :: String
- configFormat :: !Format
- defaultConfig :: Config
- func :: NFData a => String -> (b -> a) -> b -> Weigh ()
- io :: NFData a => String -> (b -> IO a) -> b -> Weigh ()
- value :: NFData a => String -> a -> Weigh ()
- action :: NFData a => String -> IO a -> Weigh ()
- wgroup :: String -> Weigh () -> Weigh ()
- validateAction :: NFData a => String -> (b -> IO a) -> b -> (Weight -> Maybe String) -> Weigh ()
- validateFunc :: NFData a => String -> (b -> a) -> b -> (Weight -> Maybe String) -> Weigh ()
- maxAllocs :: Int64 -> Weight -> Maybe String
- data Weigh a
- data Weight = Weight {
- weightLabel :: !String
- weightAllocatedBytes :: !Int64
- weightGCs :: !Int64
- weightLiveBytes :: !Int64
- weightMaxBytes :: !Int64
- commas :: (Num a, Integral a, Show a) => a -> String
- reportGroup :: Config -> [Char] -> [Grouped (Weight, Maybe String)] -> [Char]
- weighDispatch :: Maybe String -> [Grouped Action] -> IO (Maybe [Grouped Weight])
- weighFunc :: NFData a => (b -> a) -> b -> IO (Int64, Int64, Int64, Int64)
- weighAction :: NFData a => (b -> IO a) -> b -> IO (Int64, Int64, Int64, Int64)
- data Grouped a
Main entry points
weighResults :: Weigh a -> IO ([Grouped (Weight, Maybe String)], Config) Source #
Run the measuring and return all the results, each one may have an error.
Configuration
setColumns :: [Column] -> Weigh () Source #
Set the columns to display in the config
Table column.
Weigh configuration.
Config | |
|
defaultConfig :: Config Source #
Default config.
Simple combinators
:: NFData a | |
=> String | Name of the case. |
-> (b -> a) | Function that does some action to measure. |
-> b | Argument to that function. |
-> Weigh () |
Weigh a function applied to an argument.
Implemented in terms of validateFunc
.
:: NFData a | |
=> String | Name of the case. |
-> (b -> IO a) | Aciton that does some IO to measure. |
-> b | Argument to that function. |
-> Weigh () |
Weigh an action applied to an argument.
Implemented in terms of validateAction
.
Weigh a value.
Implemented in terms of action
.
Weigh an IO action.
Implemented in terms of validateAction
.
Validating combinators
:: NFData a | |
=> String | Name of the action. |
-> (b -> IO a) | The function which performs some IO. |
-> b | Argument to the function. Doesn't have to be forced. |
-> (Weight -> Maybe String) | A validating function, returns maybe an error. |
-> Weigh () |
Weigh an IO action, validating the result.
:: NFData a | |
=> String | Name of the function. |
-> (b -> a) | The function which calculates something. |
-> b | Argument to the function. Doesn't have to be forced. |
-> (Weight -> Maybe String) | A validating function, returns maybe an error. |
-> Weigh () |
Weigh a function, validating the result
Validators
Make a validator that set sthe maximum allocations.
Types
Weigh specification monad.
How much a computation weighed in at.
Weight | |
|
Handy utilities
commas :: (Num a, Integral a, Show a) => a -> String Source #
Formatting an integral number to 1,000,000, etc.
Internals
:: Maybe String | The content of then env variable WEIGH_CASE. |
-> [Grouped Action] | Weigh name:action mapping. |
-> IO (Maybe [Grouped Weight]) |
Weigh a set of actions. The value of the actions are forced completely to ensure they are fully allocated.
:: NFData a | |
=> (b -> a) | A function whose memory use we want to measure. |
-> b | Argument to the function. Doesn't have to be forced. |
-> IO (Int64, Int64, Int64, Int64) | Bytes allocated and garbage collections. |
Weigh a pure function. This function is heavily documented inside.
:: NFData a | |
=> (b -> IO a) | A function whose memory use we want to measure. |
-> b | Argument to the function. Doesn't have to be forced. |
-> IO (Int64, Int64, Int64, Int64) | Bytes allocated and garbage collections. |
Weigh an IO action. This function is heavily documented inside.
Some grouped thing.