[commit: packages/containers] ghc-head: Add fromList variants to benchmark. (cfb472c)
git at git.haskell.org
git at git.haskell.org
Fri Aug 30 13:33:42 CEST 2013
Repository : ssh://git@git.haskell.org/containers
On branch : ghc-head
Link : http://git.haskell.org/?p=packages/containers.git;a=commit;h=cfb472c87df53c37c7b54561d0b727ffbc772be0
>---------------------------------------------------------------
commit cfb472c87df53c37c7b54561d0b727ffbc772be0
Author: Milan Straka <fox at ucw.cz>
Date: Thu Aug 30 16:51:57 2012 +0200
Add fromList variants to benchmark.
Also set the size of inputs for various containers to the same value 2^12.
>---------------------------------------------------------------
cfb472c87df53c37c7b54561d0b727ffbc772be0
benchmarks/IntMap.hs | 3 +++
benchmarks/IntSet.hs | 9 ++++++---
benchmarks/Map.hs | 5 ++++-
benchmarks/Set.hs | 9 ++++++---
4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/benchmarks/IntMap.hs b/benchmarks/IntMap.hs
index 3a4d2d6..99aaa01 100644
--- a/benchmarks/IntMap.hs
+++ b/benchmarks/IntMap.hs
@@ -39,6 +39,9 @@ main = do
, bench "alter" $ whnf (alt keys) m
, bench "mapMaybe" $ whnf (M.mapMaybe maybeDel) m
, bench "mapMaybeWithKey" $ whnf (M.mapMaybeWithKey (const maybeDel)) m
+ , bench "fromList" $ whnf M.fromList elems
+ , bench "fromAscList" $ whnf M.fromAscList elems
+ , bench "fromDistinctAscList" $ whnf M.fromAscList elems
]
where
elems = zip keys values
diff --git a/benchmarks/IntSet.hs b/benchmarks/IntSet.hs
index 7844097..9f68600 100644
--- a/benchmarks/IntSet.hs
+++ b/benchmarks/IntSet.hs
@@ -32,11 +32,14 @@ main = do
, bench "union" $ whnf (S.union s_even) s_odd
, bench "difference" $ whnf (S.difference s) s_even
, bench "intersection" $ whnf (S.intersection s) s_even
+ , bench "fromList" $ whnf S.fromList elems
+ , bench "fromAscList" $ whnf S.fromAscList elems
+ , bench "fromDistinctAscList" $ whnf S.fromAscList elems
]
where
- elems = [1..2^10]
- elems_even = [2,4..2^10]
- elems_odd = [1,3..2^10]
+ elems = [1..2^12]
+ elems_even = [2,4..2^12]
+ elems_odd = [1,3..2^12]
member :: [Int] -> S.IntSet -> Int
member xs s = foldl' (\n x -> if S.member x s then n + 1 else n) 0 xs
diff --git a/benchmarks/Map.hs b/benchmarks/Map.hs
index 70a7cc9..41211c6 100644
--- a/benchmarks/Map.hs
+++ b/benchmarks/Map.hs
@@ -58,9 +58,12 @@ main = do
, bench "difference" $ whnf (M.difference m) m_even
, bench "intersection" $ whnf (M.intersection m) m_even
, bench "split" $ whnf (M.split (bound `div` 2)) m
+ , bench "fromList" $ whnf M.fromList elems
+ , bench "fromAscList" $ whnf M.fromAscList elems
+ , bench "fromDistinctAscList" $ whnf M.fromAscList elems
]
where
- bound = 2^10
+ bound = 2^12
elems = zip keys values
elems_even = zip evens evens
elems_odd = zip odds odds
diff --git a/benchmarks/Set.hs b/benchmarks/Set.hs
index 570e14c..b76a6a2 100644
--- a/benchmarks/Set.hs
+++ b/benchmarks/Set.hs
@@ -33,11 +33,14 @@ main = do
, bench "union" $ whnf (S.union s_even) s_odd
, bench "difference" $ whnf (S.difference s) s_even
, bench "intersection" $ whnf (S.intersection s) s_even
+ , bench "fromList" $ whnf S.fromList elems
+ , bench "fromAscList" $ whnf S.fromAscList elems
+ , bench "fromDistinctAscList" $ whnf S.fromAscList elems
]
where
- elems = [1..2^10]
- elems_even = [2,4..2^10]
- elems_odd = [1,3..2^10]
+ elems = [1..2^12]
+ elems_even = [2,4..2^12]
+ elems_odd = [1,3..2^12]
member :: [Int] -> S.Set Int -> Int
member xs s = foldl' (\n x -> if S.member x s then n + 1 else n) 0 xs
More information about the ghc-commits
mailing list