Copyright | (c) Ben Weitzman 2018 |
---|---|
License | MIT |
Maintainer | ben@costarastrolgoy.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Control.Monad.Freer.Profiling
Description
Synopsis
- profileEffect :: forall q r v. (Member (Writer EffectStats) r, Member IO r, Member q r, Named q) => Eff r v -> Eff r v
- class Named f
- data SingleEffectStats = SingleEffectStats {}
- newtype EffectStats = EffectStats (Map String (Map String SingleEffectStats))
- forEachStat :: Monad m => EffectStats -> (String -> String -> SingleEffectStats -> m ()) -> m ()
- drawEffectStats :: EffectStats -> String
Documentation
profileEffect :: forall q r v. (Member (Writer EffectStats) r, Member IO r, Member q r, Named q) => Eff r v -> Eff r v Source #
Automatically time and count each individual effectful compoutation. An effect that is interpreted to another effect will count towards both effects, flame graph style.
Named
is a typeclass that defines the type names and constructor names for effects.
Effects are defined as GADTs, and unfortunately, GADTs don't work well with Generics
or Data
, so this is a small typeclass that can be implemented manually to provide
the info the profiler needs.
Minimal complete definition
getDataTypeName, getConstructorName
data SingleEffectStats Source #
The stats relating to a single effect. Includes the number of times run and the total amount of time spent running.
Constructors
SingleEffectStats | |
Fields |
Instances
Show SingleEffectStats Source # | |
Defined in Control.Monad.Freer.Profiling Methods showsPrec :: Int -> SingleEffectStats -> ShowS # show :: SingleEffectStats -> String # showList :: [SingleEffectStats] -> ShowS # | |
Semigroup SingleEffectStats Source # | |
Defined in Control.Monad.Freer.Profiling Methods (<>) :: SingleEffectStats -> SingleEffectStats -> SingleEffectStats # sconcat :: NonEmpty SingleEffectStats -> SingleEffectStats # stimes :: Integral b => b -> SingleEffectStats -> SingleEffectStats # | |
Monoid SingleEffectStats Source # | |
Defined in Control.Monad.Freer.Profiling Methods mappend :: SingleEffectStats -> SingleEffectStats -> SingleEffectStats # mconcat :: [SingleEffectStats] -> SingleEffectStats # |
newtype EffectStats Source #
The stats for a whole bunch of effects
Constructors
EffectStats (Map String (Map String SingleEffectStats)) |
Instances
Show EffectStats Source # | |
Defined in Control.Monad.Freer.Profiling Methods showsPrec :: Int -> EffectStats -> ShowS # show :: EffectStats -> String # showList :: [EffectStats] -> ShowS # | |
Semigroup EffectStats Source # | |
Defined in Control.Monad.Freer.Profiling Methods (<>) :: EffectStats -> EffectStats -> EffectStats # sconcat :: NonEmpty EffectStats -> EffectStats # stimes :: Integral b => b -> EffectStats -> EffectStats # | |
Monoid EffectStats Source # | |
Defined in Control.Monad.Freer.Profiling Methods mempty :: EffectStats # mappend :: EffectStats -> EffectStats -> EffectStats # mconcat :: [EffectStats] -> EffectStats # |
forEachStat :: Monad m => EffectStats -> (String -> String -> SingleEffectStats -> m ()) -> m () Source #
Iterate through each indivudal stat
drawEffectStats :: EffectStats -> String Source #
Pretty print the effect stats