Skip to content

Commit 8b47db3

Browse files
committed
Add Applicative benchmarks
1 parent 38b1b81 commit 8b47db3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

benchmarks/Sequence.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- > ghc -DTESTING --make -O2 -fforce-recomp -i.. Sequence.hs
22
module Main where
33

4+
import Control.Applicative
45
import Control.DeepSeq
56
import Criterion.Main
67
import Data.List (foldl')
@@ -44,6 +45,22 @@ main = do
4445
, bench "nf1000" $ nf (\s -> S.fromFunction s (+1)) 1000
4546
, bench "nf10000" $ nf (\s -> S.fromFunction s (+1)) 10000
4647
]
48+
, bgroup "<*>"
49+
[ bench "ix1000/500000" $
50+
nf (\s -> ((+) <$> s <*> s) `S.index` (S.length s `div` 2)) (S.fromFunction 1000 (+1))
51+
, bench "nf100/2500/rep" $
52+
nf (\(s,t) -> (,) <$> replicate s () <*> replicate t ()) (100,2500)
53+
, bench "nf100/2500/ff" $
54+
nf (\(s,t) -> (,) <$> S.fromFunction s (+1) <*> S.fromFunction t (*2)) (100,2500)
55+
, bench "nf500/500/rep" $
56+
nf (\(s,t) -> (,) <$> replicate s () <*> replicate t ()) (500,500)
57+
, bench "nf500/500/ff" $
58+
nf (\(s,t) -> (,) <$> S.fromFunction s (+1) <*> S.fromFunction t (*2)) (500,500)
59+
, bench "nf2500/100/rep" $
60+
nf (\(s,t) -> (,) <$> replicate s () <*> replicate t ()) (2500,100)
61+
, bench "nf2500/100/ff" $
62+
nf (\(s,t) -> (,) <$> S.fromFunction s (+1) <*> S.fromFunction t (*2)) (2500,100)
63+
]
4764
]
4865

4966
-- splitAt+append: repeatedly cut the sequence at a random point

0 commit comments

Comments
 (0)