Skip to content

Commit 1f9e2ac

Browse files
committed
Add a simple benchmark to compare this implementation with the deepseq package.
1 parent d387744 commit 1f9e2ac

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

bench/Benchmark.hs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module Main where
2+
3+
import Criterion.Main
4+
import qualified "deepseq" Control.DeepSeq as D1
5+
import qualified "generic-deepseq" Control.DeepSeq as D2
6+
7+
list :: Int -> [Int]
8+
list n = [1..10^n]
9+
10+
main :: IO ()
11+
main = defaultMain
12+
[ bgroup "deepseq"
13+
[ bench "10^5 elems" $ whnf (uncurry D1.deepseq) (list 5,())
14+
, bench "10^6 elems" $ whnf (uncurry D1.deepseq) (list 6,())
15+
, bench "10^7 elems" $ whnf (uncurry D1.deepseq) (list 7,())
16+
]
17+
, bgroup "generic-deepseq"
18+
[ bench "10^5 elems" $ whnf (uncurry D2.deepseq) (list 5,())
19+
, bench "10^6 elems" $ whnf (uncurry D2.deepseq) (list 6,())
20+
, bench "10^7 elems" $ whnf (uncurry D2.deepseq) (list 7,())
21+
]
22+
]

bench/deepseq-bench.cabal

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Name: deepseq-bench
2+
Version: 1.0.0.0
3+
License-File: ../LICENSE
4+
License: BSD3
5+
Author: Maxime Henrion
6+
Copyright: 2012, Maxime Henrion
7+
Maintainer: Maxime Henrion <[email protected]>
8+
Build-Type: Simple
9+
Cabal-Version: >=1.2
10+
11+
Executable deepseq-bench
12+
Build-Depends: base, criterion, generic-deepseq, deepseq
13+
Main-is: Benchmark.hs
14+
Extensions: PackageImports
15+
GHC-Options: -Wall -O2

0 commit comments

Comments
 (0)