|
32 | 32 | bInsert, |
33 | 33 | bDelete, |
34 | 34 | bUnion, |
| 35 | + bIntersection, |
35 | 36 | bDifference |
36 | 37 | ], |
37 | 38 | bgroup "HashSet" [bSetFromList] |
@@ -262,6 +263,42 @@ bUnionEqual = |
262 | 263 | where |
263 | 264 | b size = bench (show size) . whnf (\m -> HM.union m m) |
264 | 265 |
|
| 266 | +-- TODO: For the "overlap" and "equal" cases, it would be interesting to |
| 267 | +-- have separate benchmarks both with and without shared subtrees, |
| 268 | +-- so we can make use of pointer equality. |
| 269 | +bIntersection :: Benchmark |
| 270 | +bIntersection = |
| 271 | + bgroup |
| 272 | + "intersection" |
| 273 | + [ bgroup "disjoint" bIntersectionDisjoint, |
| 274 | + bgroup "overlap" bIntersectionOverlap, |
| 275 | + bgroup "equal" bIntersectionEqual |
| 276 | + ] |
| 277 | + |
| 278 | +bIntersectionDisjoint :: [Benchmark] |
| 279 | +bIntersectionDisjoint = |
| 280 | + [ bgroup' "Bytes" genBytesMapsDisjoint b, |
| 281 | + bgroup' "Int" genIntMapsDisjoint b |
| 282 | + ] |
| 283 | + where |
| 284 | + b size = bench (show size) . whnf (\(xs, ys) -> HM.intersection xs ys) |
| 285 | + |
| 286 | +bIntersectionOverlap :: [Benchmark] |
| 287 | +bIntersectionOverlap = |
| 288 | + [ bgroup' "Bytes" genBytesMapsOverlap b, |
| 289 | + bgroup' "Int" genIntMapsOverlap b |
| 290 | + ] |
| 291 | + where |
| 292 | + b size = bench (show size) . whnf (\(xs, ys) -> HM.intersection xs ys) |
| 293 | + |
| 294 | +bIntersectionEqual :: [Benchmark] |
| 295 | +bIntersectionEqual = |
| 296 | + [ bgroup' "Bytes" genBytesMap b, |
| 297 | + bgroup' "Int" genIntMap b |
| 298 | + ] |
| 299 | + where |
| 300 | + b size = bench (show size) . whnf (\m -> HM.intersection m m) |
| 301 | + |
265 | 302 | -- TODO: For the "overlap" and "equal" cases, it would be interesting to |
266 | 303 | -- have separate benchmarks both with and without shared subtrees, |
267 | 304 | -- so we can make use of pointer equality. |
|
0 commit comments