|
1 | 1 | -- > ghc -DTESTING --make -O2 -fforce-recomp -i.. Sequence.hs
|
2 | 2 | module Main where
|
3 | 3 |
|
| 4 | +import Control.Applicative |
4 | 5 | import Control.DeepSeq
|
5 | 6 | import Criterion.Main
|
6 | 7 | import Data.List (foldl')
|
@@ -44,6 +45,22 @@ main = do
|
44 | 45 | , bench "nf1000" $ nf (\s -> S.fromFunction s (+1)) 1000
|
45 | 46 | , bench "nf10000" $ nf (\s -> S.fromFunction s (+1)) 10000
|
46 | 47 | ]
|
| 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 | + ] |
47 | 64 | ]
|
48 | 65 |
|
49 | 66 | -- splitAt+append: repeatedly cut the sequence at a random point
|
|
0 commit comments