mirror of
https://github.com/barrucadu/dejafu.git
synced 2024-11-22 03:52:12 +03:00
Turn all tests into benchmarks
This commit is contained in:
parent
ccb4b9aa24
commit
38ee90cee8
8
.weeder.yaml
Normal file
8
.weeder.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
- package:
|
||||
- name: dejafu-tests
|
||||
- section:
|
||||
- name: exe:dejafu-bench exe:dejafu-tests
|
||||
- message:
|
||||
- name: Module reused between components
|
||||
- module:
|
||||
- Util
|
@ -76,3 +76,14 @@ executable dejafu-tests
|
||||
hs-source-dirs: exe
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -threaded -rtsopts
|
||||
|
||||
executable dejafu-bench
|
||||
main-is: MainBench.hs
|
||||
other-modules: Util
|
||||
build-depends: base
|
||||
, criterion
|
||||
, dejafu-tests
|
||||
, tasty
|
||||
hs-source-dirs: exe
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -threaded -rtsopts
|
||||
|
25
dejafu-tests/exe/MainBench.hs
Normal file
25
dejafu-tests/exe/MainBench.hs
Normal file
@ -0,0 +1,25 @@
|
||||
module Main where
|
||||
|
||||
import qualified Criterion.Main as C
|
||||
import Data.Monoid (mempty)
|
||||
import qualified Test.Tasty.Options as T
|
||||
import qualified Test.Tasty.Providers as T
|
||||
import qualified Test.Tasty.Runners as T
|
||||
|
||||
import Util
|
||||
|
||||
main :: IO ()
|
||||
main = C.defaultMain (T.foldTestTree mkBench mempty tests)
|
||||
|
||||
-- | Turn a test tree into a list of benchmarks.
|
||||
mkBench :: T.TreeFold [C.Benchmark]
|
||||
mkBench = T.trivialFold
|
||||
{ T.foldSingle = \opts lbl t -> [C.bench lbl (benchTest opts t)]
|
||||
, T.foldGroup = \lbl bs -> [C.bgroup lbl bs]
|
||||
}
|
||||
|
||||
-- | Turn a test into a benchmark.
|
||||
benchTest :: T.IsTest t => T.OptionSet -> t -> C.Benchmarkable
|
||||
benchTest opts t = C.nfIO $ do
|
||||
res <- T.run opts t (\_ -> pure ())
|
||||
pure (show (T.resultOutcome res), T.resultTime res)
|
Loading…
Reference in New Issue
Block a user