@@ -18,6 +18,7 @@ import Data.Coerce
1818import Data.Tuple.Solo (Solo (MkSolo ), getSolo )
1919import System.Random (StdGen , mkStdGen , random , randoms )
2020import Prelude hiding (lookup )
21+ import Utils.Containers.Internal.Strict (StrictPair (.. ))
2122
2223import Utils.Fold (foldBenchmarks , foldWithKeyBenchmarks )
2324import Utils.Random (shuffle )
@@ -26,9 +27,10 @@ main = do
2627 let m = M. fromList elems :: M. Map Int Int
2728 m_even = M. fromList elems_even :: M. Map Int Int
2829 m_odd = M. fromList elems_odd :: M. Map Int Int
30+ s_odd_keys = M. keysSet m_odd :: Set. Set Int
2931 s_random = Set. fromList keys_random :: Set. Set Int
3032 evaluate $ rnf [m, m_even, m_odd]
31- evaluate $ rnf [s_random]
33+ evaluate $ rnf [s_random, s_odd_keys ]
3234 evaluate $ rnf
3335 [elems_distinct_asc, elems_distinct_desc, elems_asc, elems_desc]
3436 evaluate $ rnf [keys_random]
@@ -139,6 +141,7 @@ main = do
139141 , bench " Lazy.fromSetA inner" $ whnf (getSolo . M. fromSetA (MkSolo . pred )) s_random
140142 , bench " Strict.fromSetA inner" $ whnf (getSolo . MS. fromSetA (MkSolo . pred )) s_random
141143 , 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 ])
144+
142145 , bench " eq" $ whnf (\ m' -> m' == m') m -- worst case, compares everything
143146 , bench " compare" $ whnf (\ m' -> compare m' m') m -- worst case, compares everything
144147 , bgroup " folds" $ foldBenchmarks M. foldr M. foldl M. foldr' M. foldl' foldMap m
@@ -148,6 +151,10 @@ main = do
148151 , bench " mapKeys:desc" $ whnf (M. mapKeys (negate . (+ 1 ))) m
149152 , bench " mapKeysWith:asc" $ whnf (M. mapKeysWith (+) (`div` 2 )) m
150153 , bench " mapKeysWith:desc" $ whnf (M. mapKeysWith (+) (negate . (`div` 2 ))) m
154+
155+ , bench " restrictKeys" $ whnf (M. restrictKeys m) s_odd_keys
156+ , bench " withoutKeys" $ whnf (M. withoutKeys m) s_odd_keys
157+ , bench " partitionKeys" $ whnf (M. partitionKeys m) s_odd_keys
151158 ]
152159 where
153160 bound = 2 ^ 14
0 commit comments