Permalink
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (17 sloc) 444 Bytes
-- The simplest/silliest of all benchmarks!
import Criterion.Main
fib :: Integer -> Integer
fib m | m < 0 = error "negative!"
| 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
]
]