/
Benchmark.purs
36 lines (31 loc) · 1.18 KB
/
Benchmark.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Benchmark
( module Benchmark.Suite.Monad
, module Benchmark.Output
, module Benchmark.Function
, module Suite
, module STModule
, runBench
, fnEff
, fn
) where
import Benchmark.Suite.Monad (SuiteM, SuiteT, accumulateResults, add, on, run,
runSuiteM, runSuiteT)
import Benchmark.Suite (Suite) as Suite
import Benchmark.Suite.ST (BenchmarkResult) as STModule
import Benchmark.Output (printResultOnCycle, printResultTableOnComplete)
import Benchmark.Function (fn1)
import Prelude (Unit, ($), (*>))
import Control.Monad.ST as ST
import Control.Monad.Eff (Eff)
-- | Runs the benchmark suite and print results. Use `fn` and `fnEff` inside the
-- | monadic interface to add functions to the suite.
-- | >>> runBench $ do
-- | >>> fn "function name" (_ + 40) 2
-- | >>> fnEff "eff function name" (log "eff function executed")
runBench :: forall s e a.
SuiteT s (st :: ST.ST s | e ) a -> Eff (st :: ST.ST s | e ) Unit
runBench m = runSuiteM $ m *> printResultTableOnComplete
fnEff :: forall s m e anyEff a. SuiteM s e m (String -> Eff anyEff a -> m Unit)
fnEff = add
fn :: forall s m e a b. SuiteM s e m (String -> (a -> b) -> a -> m Unit)
fn s f a = add s (fn1 f a)