Safe Haskell | None |
---|---|
Language | Haskell2010 |
Tools for benchmarking and accumulating results. Nothing Agda-specific in here.
Synopsis
- type Account a = [a]
- type CurrentAccount a = Maybe (Account a, CPUTime)
- type Timings a = Trie a CPUTime
- data BenchmarkOn a
- = BenchmarkOff
- | BenchmarkOn
- | BenchmarkSome (Account a -> Bool)
- isBenchmarkOn :: Account a -> BenchmarkOn a -> Bool
- data Benchmark a = Benchmark {
- benchmarkOn :: !(BenchmarkOn a)
- currentAccount :: !(CurrentAccount a)
- timings :: !(Timings a)
- mapBenchmarkOn :: (BenchmarkOn a -> BenchmarkOn a) -> Benchmark a -> Benchmark a
- mapCurrentAccount :: (CurrentAccount a -> CurrentAccount a) -> Benchmark a -> Benchmark a
- mapTimings :: (Timings a -> Timings a) -> Benchmark a -> Benchmark a
- addCPUTime :: Ord a => Account a -> CPUTime -> Benchmark a -> Benchmark a
- class (Ord (BenchPhase m), Functor m, MonadIO m) => MonadBench (m :: Type -> Type) where
- type BenchPhase (m :: Type -> Type)
- getBenchmark :: m (Benchmark (BenchPhase m))
- putBenchmark :: Benchmark (BenchPhase m) -> m ()
- modifyBenchmark :: (Benchmark (BenchPhase m) -> Benchmark (BenchPhase m)) -> m ()
- finally :: m b -> m c -> m b
- getsBenchmark :: MonadBench m => (Benchmark (BenchPhase m) -> c) -> m c
- setBenchmarking :: MonadBench m => BenchmarkOn (BenchPhase m) -> m ()
- switchBenchmarking :: MonadBench m => Maybe (Account (BenchPhase m)) -> m (Maybe (Account (BenchPhase m)))
- reset :: MonadBench m => m ()
- billTo :: MonadBench m => Account (BenchPhase m) -> m c -> m c
- billToCPS :: MonadBench m => Account (BenchPhase m) -> ((b -> m c) -> m c) -> (b -> m c) -> m c
- billPureTo :: MonadBench m => Account (BenchPhase m) -> c -> m c
Benchmark trie
type CurrentAccount a = Maybe (Account a, CPUTime) Source #
Record when we started billing the current account.
data BenchmarkOn a Source #
Instances
isBenchmarkOn :: Account a -> BenchmarkOn a -> Bool Source #
Benchmark structure is a trie, mapping accounts (phases and subphases) to CPU time spent on their performance.
Benchmark | |
|
Instances
(Ord a, Pretty a) => Pretty (Benchmark a) Source # | Print benchmark as three-column table with totals. | ||||
Null (Benchmark a) Source # | Initial benchmark structure (empty). | ||||
Generic (Benchmark a) Source # | |||||
Defined in Agda.Utils.Benchmark
| |||||
NFData a => NFData (Benchmark a) Source # | |||||
Defined in Agda.Utils.Benchmark | |||||
type Rep (Benchmark a) Source # | |||||
Defined in Agda.Utils.Benchmark type Rep (Benchmark a) = D1 ('MetaData "Benchmark" "Agda.Utils.Benchmark" "Agda-2.6.4.1-inplace" 'False) (C1 ('MetaCons "Benchmark" 'PrefixI 'True) (S1 ('MetaSel ('Just "benchmarkOn") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (BenchmarkOn a)) :*: (S1 ('MetaSel ('Just "currentAccount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (CurrentAccount a)) :*: S1 ('MetaSel ('Just "timings") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Timings a))))) |
mapBenchmarkOn :: (BenchmarkOn a -> BenchmarkOn a) -> Benchmark a -> Benchmark a Source #
Semantic editor combinator.
mapCurrentAccount :: (CurrentAccount a -> CurrentAccount a) -> Benchmark a -> Benchmark a Source #
Semantic editor combinator.
mapTimings :: (Timings a -> Timings a) -> Benchmark a -> Benchmark a Source #
Semantic editor combinator.
addCPUTime :: Ord a => Account a -> CPUTime -> Benchmark a -> Benchmark a Source #
Add to specified CPU time account.
Benchmarking monad.
class (Ord (BenchPhase m), Functor m, MonadIO m) => MonadBench (m :: Type -> Type) where Source #
Monad with access to benchmarking data.
type BenchPhase (m :: Type -> Type) Source #
getBenchmark :: m (Benchmark (BenchPhase m)) Source #
putBenchmark :: Benchmark (BenchPhase m) -> m () Source #
modifyBenchmark :: (Benchmark (BenchPhase m) -> Benchmark (BenchPhase m)) -> m () Source #
finally :: m b -> m c -> m b Source #
We need to be able to terminate benchmarking in case of an exception.
Instances
MonadBench TerM Source # | |||||
Defined in Agda.Termination.Monad
getBenchmark :: TerM (Benchmark (BenchPhase TerM)) Source # putBenchmark :: Benchmark (BenchPhase TerM) -> TerM () Source # modifyBenchmark :: (Benchmark (BenchPhase TerM) -> Benchmark (BenchPhase TerM)) -> TerM () Source # | |||||
MonadBench TCM Source # | We store benchmark statistics in an IORef. This enables benchmarking pure computation, see Agda.Benchmarking. | ||||
Defined in Agda.TypeChecking.Monad.Base
getBenchmark :: TCM (Benchmark (BenchPhase TCM)) Source # putBenchmark :: Benchmark (BenchPhase TCM) -> TCM () Source # modifyBenchmark :: (Benchmark (BenchPhase TCM) -> Benchmark (BenchPhase TCM)) -> TCM () Source # | |||||
MonadBench IO Source # | |||||
Defined in Agda.Benchmarking
getBenchmark :: IO (Benchmark (BenchPhase IO)) Source # putBenchmark :: Benchmark (BenchPhase IO) -> IO () Source # modifyBenchmark :: (Benchmark (BenchPhase IO) -> Benchmark (BenchPhase IO)) -> IO () Source # | |||||
MonadBench m => MonadBench (ListT m) Source # | |||||
Defined in Agda.Utils.Benchmark
getBenchmark :: ListT m (Benchmark (BenchPhase (ListT m))) Source # putBenchmark :: Benchmark (BenchPhase (ListT m)) -> ListT m () Source # modifyBenchmark :: (Benchmark (BenchPhase (ListT m)) -> Benchmark (BenchPhase (ListT m))) -> ListT m () Source # | |||||
MonadBench m => MonadBench (ExceptT e m) Source # | |||||
Defined in Agda.Utils.Benchmark
getBenchmark :: ExceptT e m (Benchmark (BenchPhase (ExceptT e m))) Source # putBenchmark :: Benchmark (BenchPhase (ExceptT e m)) -> ExceptT e m () Source # modifyBenchmark :: (Benchmark (BenchPhase (ExceptT e m)) -> Benchmark (BenchPhase (ExceptT e m))) -> ExceptT e m () Source # finally :: ExceptT e m b -> ExceptT e m c -> ExceptT e m b Source # | |||||
MonadBench m => MonadBench (ReaderT r m) Source # | |||||
Defined in Agda.Utils.Benchmark
getBenchmark :: ReaderT r m (Benchmark (BenchPhase (ReaderT r m))) Source # putBenchmark :: Benchmark (BenchPhase (ReaderT r m)) -> ReaderT r m () Source # modifyBenchmark :: (Benchmark (BenchPhase (ReaderT r m)) -> Benchmark (BenchPhase (ReaderT r m))) -> ReaderT r m () Source # finally :: ReaderT r m b -> ReaderT r m c -> ReaderT r m b Source # | |||||
MonadBench m => MonadBench (StateT r m) Source # | |||||
Defined in Agda.Utils.Benchmark
getBenchmark :: StateT r m (Benchmark (BenchPhase (StateT r m))) Source # putBenchmark :: Benchmark (BenchPhase (StateT r m)) -> StateT r m () Source # modifyBenchmark :: (Benchmark (BenchPhase (StateT r m)) -> Benchmark (BenchPhase (StateT r m))) -> StateT r m () Source # finally :: StateT r m b -> StateT r m c -> StateT r m b Source # | |||||
(MonadBench m, Monoid w) => MonadBench (WriterT w m) Source # | |||||
Defined in Agda.Utils.Benchmark
getBenchmark :: WriterT w m (Benchmark (BenchPhase (WriterT w m))) Source # putBenchmark :: Benchmark (BenchPhase (WriterT w m)) -> WriterT w m () Source # modifyBenchmark :: (Benchmark (BenchPhase (WriterT w m)) -> Benchmark (BenchPhase (WriterT w m))) -> WriterT w m () Source # finally :: WriterT w m b -> WriterT w m c -> WriterT w m b Source # |
getsBenchmark :: MonadBench m => (Benchmark (BenchPhase m) -> c) -> m c Source #
setBenchmarking :: MonadBench m => BenchmarkOn (BenchPhase m) -> m () Source #
Turn benchmarking on/off.
:: MonadBench m | |
=> Maybe (Account (BenchPhase m)) | Maybe new account. |
-> m (Maybe (Account (BenchPhase m))) | Maybe old account. |
Bill current account with time up to now. Switch to new account. Return old account (if any).
reset :: MonadBench m => m () Source #
Resets the account and the timing information.
billTo :: MonadBench m => Account (BenchPhase m) -> m c -> m c Source #
Bill a computation to a specific account. Works even if the computation is aborted by an exception.
billToCPS :: MonadBench m => Account (BenchPhase m) -> ((b -> m c) -> m c) -> (b -> m c) -> m c Source #
Bill a CPS function to an account. Can't handle exceptions.
billPureTo :: MonadBench m => Account (BenchPhase m) -> c -> m c Source #
Bill a pure computation to a specific account.