Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion AdventOfCode2020.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ library
Paths_AdventOfCode2020
hs-source-dirs:
src
ghc-options: -Wall -O2
build-tool-depends:
hlint:hlint
, hpc-lcov:hpc-lcov
Expand Down Expand Up @@ -112,7 +113,7 @@ test-suite AdventOfCode2020-test
Paths_AdventOfCode2020
hs-source-dirs:
test
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
ghc-options: -Wall -O2 -threaded -rtsopts -with-rtsopts=-N -Wall -O2
build-tool-depends:
hlint:hlint
, hpc-lcov:hpc-lcov
Expand All @@ -128,3 +129,25 @@ test-suite AdventOfCode2020-test
, parsec
, unordered-containers
default-language: Haskell2010

benchmark AdventOfCode2020-bench
type: exitcode-stdio-1.0
main-is: Bench.hs
other-modules:
Paths_AdventOfCode2020
hs-source-dirs:
bench
ghc-options: -Wall -O2 -threaded -rtsopts -with-rtsopts=-N -Wall -O2
build-tool-depends:
hlint:hlint
, hpc-lcov:hpc-lcov
, implicit-hie:implicit-hie
build-depends:
AdventOfCode2020
, base >=4.7 && <5
, containers
, criterion
, hashable
, parsec
, unordered-containers
default-language: Haskell2010
22 changes: 22 additions & 0 deletions bench/Bench.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Criterion.Main

fib :: Integer -> Integer
fib m
| m < 0 = undefined
| otherwise = go m
where
go 0 = 0
go 1 = 1
go n = go (n + 1) + go (n -2)

main :: IO ()
main =
defaultMain
[ bgroup
"fib"
[ bench "1" $ whnf fib 1,
bench "5" $ whnf fib 5,
bench "9" $ whnf fib 9,
bench "11" $ whnf fib 11
]
]
589 changes: 589 additions & 0 deletions fibber2.html

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ cradle:

- path: "./test"
component: "AdventOfCode2020:test:AdventOfCode2020-test"

- path: "./bench/Bench.hs"
component: "AdventOfCode2020:bench:AdventOfCode2020-bench"

- path: "./bench/Paths_AdventOfCode2020.hs"
component: "AdventOfCode2020:bench:AdventOfCode2020-bench"
20 changes: 20 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ dependencies:
- parsec
- unordered-containers

ghc-options:
- -Wall
- -O2

library:
source-dirs: src

Expand All @@ -38,13 +42,29 @@ tests:
- -rtsopts
- -with-rtsopts=-N
- -Wall
- -O2

dependencies:
- AdventOfCode2020
- hspec-discover
- hspec
- hspec-golden

benchmarks:
AdventOfCode2020-bench:
main: Bench.hs
source-dirs: bench
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -Wall
- -O2

dependencies:
- AdventOfCode2020
- criterion

build-tools:
- implicit-hie
- hpc-lcov
Expand Down