[commit: packages/containers] zip-devel: Add simple mapWithIndex benchmark. (0f3ac0b)

git at git.haskell.org git at git.haskell.org
Sun Dec 20 16:22:21 UTC 2015


Repository : ssh://git@git.haskell.org/containers

On branch  : zip-devel
Link       : http://git.haskell.org/packages/containers.git/commitdiff/0f3ac0b3e48f49e5565b692f2abcb2219895d145

>---------------------------------------------------------------

commit 0f3ac0b3e48f49e5565b692f2abcb2219895d145
Author: Milan Straka <fox at ucw.cz>
Date:   Sun Dec 7 15:43:09 2014 +0100

    Add simple mapWithIndex benchmark.


>---------------------------------------------------------------

0f3ac0b3e48f49e5565b692f2abcb2219895d145
 benchmarks/Sequence.hs | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/benchmarks/Sequence.hs b/benchmarks/Sequence.hs
index 58e1114..5ae2cd3 100644
--- a/benchmarks/Sequence.hs
+++ b/benchmarks/Sequence.hs
@@ -12,7 +12,8 @@ main = do
     let s10 = S.fromList [1..10] :: S.Seq Int
         s100 = S.fromList [1..100] :: S.Seq Int
         s1000 = S.fromList [1..1000] :: S.Seq Int
-    rnf [s10, s100, s1000] `seq` return ()
+        s10000 = S.fromList [1..10000] :: S.Seq Int
+    rnf [s10, s100, s1000, s10000] `seq` return ()
     let g = mkStdGen 1
     let rlist n = map (`mod` (n+1)) (take 10000 (randoms g)) :: [Int]
         r10 = rlist 10
@@ -35,6 +36,11 @@ main = do
          , bench "nf100" $ nf (\size -> S.fromFunction size id) 100
          , bench "nf10000" $ nf (\size -> S.fromFunction size id) 10000
          ]
+      , bgroup "mapWithIndex"
+         [ bench "ix10000/5000" $ nf (S.mapWithIndex (+)) s10000
+         , bench "nf100" $ nf (S.mapWithIndex (+)) s100
+         , bench "nf10000" $ nf (S.mapWithIndex (+)) s10000
+         ]
       ]
 
 -- splitAt+append: repeatedly cut the sequence at a random point



More information about the ghc-commits mailing list