Skip to content

Commit 69c2cb3

Browse files
committed
WIP
1 parent 2e54971 commit 69c2cb3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

benchmarks/FineGrained.hs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,27 @@ bUnionDisjoint =
8585
let (trues, falses) = Data.List.partition (flip testBit (31 :: Int)) ints
8686
return (HM.fromList (map (,()) trues), HM.fromList (map (,()) falses))
8787

88+
-- TODO: Separate benchmarks for overlap with pointer eq?!
8889
bUnionOverlap :: [Benchmark]
89-
bUnionOverlap = undefined
90+
bUnionOverlap =
91+
[ -- bgroup "Bytes" [env (bytesEnv s) (bench' s) | s <- defaultSizes],
92+
bgroup "Int" [env (intsEnv s) (bench' s) | s <- defaultSizes]
93+
]
94+
where
95+
bench' s tup = bench (show s) $ whnf (\(as, bs) -> HM.union as bs) tup
96+
bytesEnv s = do
97+
g <- newIOGenM defaultGen
98+
undefined
99+
intsEnv s = do
100+
g <- newIOGenM defaultGen
101+
let s_overlap = s `div` 2
102+
let s_a_sep = (s - s_overlap) `div` 2
103+
let s_b_sep = s - s_overlap - s_a_sep
104+
overlap <- genInts s_overlap g
105+
a_sep <- genInts s_a_sep g
106+
b_sep <- genInts s_b_sep g
107+
let toMap = HM.fromList . map (,())
108+
return (toMap overlap `HM.union` toMap a_sep, toMap overlap `HM.union` toMap b_sep)
90109

91110
genInts ::
92111
(StatefulGen g m) =>

0 commit comments

Comments
 (0)