Skip to content

Commit d2acc7c

Browse files
committed
Use sumkv
1 parent 868523b commit d2acc7c

File tree

1 file changed

+10
-6
lines changed
  • containers-tests/benchmarks

1 file changed

+10
-6
lines changed

containers-tests/benchmarks/Map.hs

+10-6
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ main = do
7171
, bench "insertLookupWithKey' present" $ whnf (insLookupWithKey' elems_even) m_even
7272
, bench "mapWithKey" $ whnf (M.mapWithKey (+)) m
7373
, bench "foldlWithKey" $ whnf (ins elems) m
74-
, bench "foldlWithKey'" $ whnf (M.foldlWithKey' sum 0) m
74+
, bench "foldlWithKey'" $ whnf (M.foldlWithKey' sumkv 0) m
7575
, bench "foldrWithKey" $ whnf (M.foldrWithKey consPair []) m
7676
, bench "foldrWithKey'" $ whnf (M.foldrWithKey' consPair []) m
7777
, bench "update absent" $ whnf (upd Just evens) m_odd
@@ -90,13 +90,17 @@ main = do
9090
, bench "fromList" $ whnf M.fromList elems
9191
, bench "fromList-desc" $ whnf M.fromList elems_desc
9292
, bench "fromAscList" $ whnf M.fromAscList elems_asc
93-
, bench "fromAscListWithKey" $ whnf (M.fromAscListWithKey (\k v2 v1 -> k + v2 + v1)) elems_asc
93+
, bench "fromAscListWithKey" $
94+
whnf (M.fromAscListWithKey sumkv) elems_asc
9495
, bench "fromDescList" $ whnf M.fromDescList elems_desc
95-
, bench "fromDescListWithKey" $ whnf (M.fromDescListWithKey (\k v2 v1 -> k + v2 + v1)) elems_desc
96+
, bench "fromDescListWithKey" $
97+
whnf (M.fromDescListWithKey sumkv) elems_desc
9698
, bench "fromDistinctAscList" $ whnf M.fromDistinctAscList elems
97-
, bench "fromDistinctAscList:fusion" $ whnf (\n -> M.fromDistinctAscList [(i,i) | i <- [1..n]]) bound
99+
, bench "fromDistinctAscList:fusion" $
100+
whnf (\n -> M.fromDistinctAscList [(i,i) | i <- [1..n]]) bound
98101
, bench "fromDistinctDescList" $ whnf M.fromDistinctDescList elems_rev
99-
, bench "fromDistinctDescList:fusion" $ whnf (\n -> M.fromDistinctDescList [(i,i) | i <- [n,n-1..1]]) bound
102+
, bench "fromDistinctDescList:fusion" $
103+
whnf (\n -> M.fromDistinctDescList [(i,i) | i <- [n,n-1..1]]) bound
100104
, bench "minView" $ whnf (\m' -> case M.minViewWithKey m' of {Nothing -> 0; Just ((k,v),m'') -> k+v+M.size m''}) (M.fromAscList $ zip [1..10::Int] [100..110::Int])
101105
, bench "eq" $ whnf (\m' -> m' == m') m -- worst case, compares everything
102106
, bench "compare" $ whnf (\m' -> compare m' m') m -- worst case, compares everything
@@ -115,7 +119,7 @@ main = do
115119
evens = [2,4..bound]
116120
odds = [1,3..bound]
117121
values = [1..bound]
118-
sum k v1 v2 = k + v1 + v2
122+
sumkv k v1 v2 = k + v1 + v2
119123
consPair k v xs = (k, v) : xs
120124

121125
add3 :: Int -> Int -> Int -> Int

0 commit comments

Comments
 (0)