Safe Haskell | None |
---|---|
Language | Haskell2010 |
Using this library you can create executables with benchmarks. It automatically implants a command-line options parser and info generator.
Here is an example of how this library is supposed to be used:
import CriterionPlus import qualified SomeMySQLLib as MySQL import qualified SomePostgreSQLLib as PostgreSQL main = benchmark $ do standoff "Inserting rows" $ do subject "MySQL" $ do -- Exclude the "setup" phase from measurement: pause connection <- liftIO $ MySQL.openConnection -- Measure what we want: continue liftIO $ MySQL.insertAThousandRows connection -- Exclude the "teardown" phase from measurement: pause liftIO $ MySQL.closeConnection connection subject "PostgreSQL" $ do -- This is how we can exclude the "setup" phase from monad transformers: pause PostgreSQL.runSession $ do lift $ continue PostgreSQL.insertAThousandRows -- Exclude "teardown": lift $ pause -- Each standoff generates an independent report file: standoff "Querying" $ do subject "MySQL" $ error "So on..." subject "PostgreSQL" $ error "So on..."
- benchmark :: Benchmark () -> IO ()
- data Benchmark a
- standoff :: Name -> Standoff () -> Benchmark ()
- data Standoff a
- group :: Name -> Standoff () -> Standoff ()
- subject :: Name -> Subject a -> Standoff ()
- data Subject a
- continue :: Subject ()
- pause :: Subject ()
- whnf :: MonadIO m => (a -> b) -> a -> m ()
- nf :: (MonadIO m, NFData b) => (a -> b) -> a -> m ()
- nfIO :: (MonadIO m, NFData a) => IO a -> m ()
- whnfIO :: MonadIO m => IO a -> m ()
- type Name = StrictText
IO
Benchmark
standoff :: Name -> Standoff () -> Benchmark () Source
Declare a named comparison of multiple subjects. This will generate a separate report file.
Standoff
group :: Name -> Standoff () -> Standoff () Source
Put the wrapped computations into a named group. Can be nested.
Subject
A monad, which wraps the benchmarking subject and controls its measurement.
Continue the timer.
By default it is already running,
so if you need to eclude something from the beginning of the subject
use pause
. E.g.:
subject "MySQL" $ do pause connection <- liftIO $ openConnection continue liftIO $ workWithConnection connection pause liftIO $ closeConnection connection
Evaluation
Shared Types
type Name = StrictText Source