Skip to content

Commit 1646f9a

Browse files
committed
WIP
1 parent 24e8645 commit 1646f9a

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed

benchmarks/FineGrained.hs

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ main =
2626
[ bgroup
2727
"HashMap.Strict"
2828
[ bFromList,
29-
-- bgroup "insert" bInsert
29+
bInsert,
3030
bUnion,
3131
bDifference
3232
],
@@ -59,6 +59,45 @@ bFromList =
5959
setupBytes s gen = genNBytes s bytesLength gen
6060
b s = bench (show s) . whnf (HM.fromList . map (,()))
6161

62+
bInsert :: Benchmark
63+
bInsert =
64+
bgroup
65+
"insert"
66+
[ bgroup "present" bInsertPresent,
67+
bgroup "absent" bInsertAbsent
68+
]
69+
70+
bInsertPresent :: [Benchmark]
71+
bInsertPresent =
72+
[ bgroup' "Bytes" undefined b,
73+
bgroup' "Int" setupInts b
74+
]
75+
where
76+
setupInts size gen = do
77+
m <- genIntMap size gen
78+
let ks = Data.List.repeat (HM.keys m)
79+
return (m, take 100 ks)
80+
b s = bench (show s) . undefined
81+
82+
bInsertAbsent :: [Benchmark]
83+
bInsertAbsent =
84+
[ bgroup' "Bytes" genBytesMapsDisjoint b,
85+
bgroup' "Int" genIntMapsDisjoint b
86+
]
87+
where
88+
b s = bench (show s) . whnf (\(as, bs) -> HM.union as bs)
89+
90+
{-
91+
- [ env m $ \d -> bench (show s) $ whnf (\(k, v, m) -> HM.insert k v m) d ]
92+
where m s = do
93+
g <- newIOGenM defaultGen
94+
let hm = HM.empty
95+
forM_ [1..s] $ \v -> do
96+
b <- genBytes 32 g
97+
HMI.unsafeInsert b v hm
98+
return (m, newKeys) -- separate existing, new
99+
-}
100+
62101
-- TODO: For the "overlap" and "equal" cases, it would be interesting to
63102
-- have separate benchmarks both with and without shared subtrees,
64103
-- so we can make use of pointer equality.
@@ -141,17 +180,6 @@ bSetFromList =
141180
where
142181
b size = bench (show size) . whnf Data.HashSet.fromList
143182

144-
{-
145-
bInsert = [ env m $ \d -> bench (show s) $ whnf (\(k, v, m) -> HM.insert k v m) d ]
146-
where m s = do
147-
g <- newIOGenM defaultGen
148-
let hm = HM.empty
149-
forM_ [1..s] $ \v -> do
150-
b <- genBytes 32 g
151-
HMI.unsafeInsert b v hm
152-
return (m, newKeys) -- separate existing, new
153-
-}
154-
155183
-------------------------------------------------------------------------------
156184
-- Boilerplate
157185

0 commit comments

Comments
 (0)