mirror of
https://github.com/Bodigrim/tasty-bench.git
synced 2024-08-17 04:30:21 +03:00
Add bench-fibo example as proper benchmark
Also move sources to src/ so there are no accidental rebuilding.
This commit is contained in:
parent
1fb79b5d0a
commit
3790437ae4
2
.github/workflows/other.yml
vendored
2
.github/workflows/other.yml
vendored
@ -65,4 +65,4 @@ jobs:
|
||||
apt-get install -y ghc libghc-tasty-dev
|
||||
run: |
|
||||
ghc --version
|
||||
ghc Test/Tasty/Bench.hs
|
||||
ghc src/Test/Tasty/Bench.hs
|
||||
|
15
bench/bench-fibo.hs
Normal file
15
bench/bench-fibo.hs
Normal file
@ -0,0 +1,15 @@
|
||||
module Main (main) where
|
||||
|
||||
import Test.Tasty.Bench
|
||||
|
||||
fibo :: Int -> Integer
|
||||
fibo n = if n < 2 then toInteger n else fibo (n - 1) + fibo (n - 2)
|
||||
|
||||
main :: IO ()
|
||||
main = defaultMain
|
||||
[ bgroup "fibonacci numbers"
|
||||
[ bench "fifth" $ nf fibo 5
|
||||
, bench "tenth" $ nf fibo 10
|
||||
, bench "twentieth" $ nf fibo 20
|
||||
]
|
||||
]
|
@ -45,7 +45,7 @@ flag debug
|
||||
|
||||
library
|
||||
exposed-modules: Test.Tasty.Bench
|
||||
hs-source-dirs: .
|
||||
hs-source-dirs: src
|
||||
default-language: Haskell2010
|
||||
ghc-options: -O2 -Wall -fno-warn-unused-imports
|
||||
if impl(ghc < 7.10)
|
||||
@ -66,3 +66,11 @@ library
|
||||
|
||||
if flag(debug)
|
||||
cpp-options: -DDEBUG
|
||||
|
||||
benchmark bench-fibo
|
||||
default-language: Haskell2010
|
||||
hs-source-dirs: bench
|
||||
main-is: bench-fibo.hs
|
||||
type: exitcode-stdio-1.0
|
||||
build-depends: base, tasty-bench
|
||||
ghc-options: "-with-rtsopts=-A32m"
|
||||
|
Loading…
Reference in New Issue
Block a user