Agda-2.6.0.1: A dependently typed functional programming language and proof assistant

Safe Haskell | None
Language | Haskell2010

Agda.Utils.Benchmark

Contents

- Benchmark trie
- Benchmarking monad.

Description

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 a, Functor m, MonadIO m) => MonadBench a m | m -> a where
  - getBenchmark :: m (Benchmark a)
  - getsBenchmark :: (Benchmark a -> c) -> m c
  - putBenchmark :: Benchmark a -> m ()
  - modifyBenchmark :: (Benchmark a -> Benchmark a) -> m ()
  - finally :: m b -> m c -> m b
- setBenchmarking :: MonadBench a m => BenchmarkOn a -> m ()
- switchBenchmarking :: MonadBench a m => Maybe (Account a) -> m (Maybe (Account a))
- reset :: MonadBench a m => m ()
- billTo :: MonadBench a m => Account a -> m c -> m c
- billToCPS :: MonadBench a m => Account a -> ((b -> m c) -> m c) -> (b -> m c) -> m c
- billPureTo :: MonadBench a m => Account a -> c -> m c

# Benchmark trie

type Account a = [a] Source #

Account we can bill computation time to.

type CurrentAccount a = Maybe (Account a, CPUTime) Source #

Record when we started billing the current account.

type Timings a = Trie a CPUTime Source #

data BenchmarkOn a Source #

Constructors

BenchmarkOff |
BenchmarkOn |
BenchmarkSome (Account a -> Bool) |

isBenchmarkOn :: Account a -> BenchmarkOn a -> Bool Source #

data Benchmark a Source #

Benchmark structure is a trie, mapping accounts (phases and subphases) to CPU time spent on their performance.

Constructors

Benchmark |

Fields

- benchmarkOn :: !(BenchmarkOn a)

  Are we benchmarking at all?

- currentAccount :: !(CurrentAccount a)

  What are we billing to currently?

- timings :: !(Timings a)

  The accounts and their accumulated timing bill.

Instances

Null (Benchmark a) Source # | Initial benchmark structure (empty).
Instance details Defined in Agda.Utils.Benchmark Methods empty :: Benchmark a Source # null :: Benchmark a -> Bool Source #
(Ord a, Pretty a) => Pretty (Benchmark a) Source # | Print benchmark as three-column table with totals.
Instance details Defined in Agda.Utils.Benchmark Methods pretty :: Benchmark a -> Doc Source # prettyPrec :: Int -> Benchmark a -> Doc Source # prettyList :: [Benchmark a] -> Doc Source #

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 a, Functor m, MonadIO m) => MonadBench a m | m -> a where Source #

Monad with access to benchmarking data.

Minimal complete definition

getBenchmark, finally

Methods

getBenchmark :: m (Benchmark a) Source #

getsBenchmark :: (Benchmark a -> c) -> m c Source #

putBenchmark :: Benchmark a -> m () Source #

modifyBenchmark :: (Benchmark a -> Benchmark a) -> 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 Phase IO Source # |
Instance details Defined in Agda.Benchmarking Methods getBenchmark :: IO (Benchmark Phase) Source # getsBenchmark :: (Benchmark Phase -> c) -> IO c Source # putBenchmark :: Benchmark Phase -> IO () Source # modifyBenchmark :: (Benchmark Phase -> Benchmark Phase) -> IO () Source # finally :: IO b -> IO c -> IO b Source #
MonadBench Phase TCM Source # | We store benchmark statistics in an IORef. This enables benchmarking pure computation, see Agda.Benchmarking.
Instance details Defined in Agda.TypeChecking.Monad.Base Methods getBenchmark :: TCM (Benchmark Phase) Source # getsBenchmark :: (Benchmark Phase -> c) -> TCM c Source # putBenchmark :: Benchmark Phase -> TCM () Source # modifyBenchmark :: (Benchmark Phase -> Benchmark Phase) -> TCM () Source # finally :: TCM b -> TCM c -> TCM b Source #
MonadBench Phase TerM Source # |
Instance details Defined in Agda.Termination.Monad Methods getBenchmark :: TerM (Benchmark Phase) Source # getsBenchmark :: (Benchmark Phase -> c) -> TerM c Source # putBenchmark :: Benchmark Phase -> TerM () Source # modifyBenchmark :: (Benchmark Phase -> Benchmark Phase) -> TerM () Source # finally :: TerM b -> TerM c -> TerM b Source #
MonadBench a m => MonadBench a (StateT r m) Source # |
Instance details Defined in Agda.Utils.Benchmark Methods getBenchmark :: StateT r m (Benchmark a) Source # getsBenchmark :: (Benchmark a -> c) -> StateT r m c Source # putBenchmark :: Benchmark a -> StateT r m () Source # modifyBenchmark :: (Benchmark a -> Benchmark a) -> StateT r m () Source # finally :: StateT r m b -> StateT r m c -> StateT r m b Source #
MonadBench a m => MonadBench a (ReaderT r m) Source # |
Instance details Defined in Agda.Utils.Benchmark Methods getBenchmark :: ReaderT r m (Benchmark a) Source # getsBenchmark :: (Benchmark a -> c) -> ReaderT r m c Source # putBenchmark :: Benchmark a -> ReaderT r m () Source # modifyBenchmark :: (Benchmark a -> Benchmark a) -> ReaderT r m () Source # finally :: ReaderT r m b -> ReaderT r m c -> ReaderT r m b Source #

setBenchmarking :: MonadBench a m => BenchmarkOn a -> m () Source #

Turn benchmarking on/off.

switchBenchmarking Source #

Arguments

:: MonadBench a m |
=> Maybe (Account a) | Maybe new account.
-> m (Maybe (Account a)) | Maybe old account.

Bill current account with time up to now. Switch to new account. Return old account (if any).

reset :: MonadBench a m => m () Source #

Resets the account and the timing information.

billTo :: MonadBench a m => Account a -> m c -> m c Source #

Bill a computation to a specific account. Works even if the computation is aborted by an exception.

billToCPS :: MonadBench a m => Account a -> ((b -> m c) -> m c) -> (b -> m c) -> m c Source #

Bill a CPS function to an account. Can't handle exceptions.

billPureTo :: MonadBench a m => Account a -> c -> m c Source #

Bill a pure computation to a specific account.