@@ -5,7 +5,7 @@ module Main where
5
5
import Control.Applicative (Const (Const , getConst ), pure )
6
6
import Control.DeepSeq (rnf )
7
7
import Control.Exception (evaluate )
8
- import Test.Tasty.Bench (bench , defaultMain , whnf , nf )
8
+ import Test.Tasty.Bench (bench , defaultMain , whnf , nf , bcompare )
9
9
import Data.Functor.Identity (Identity (.. ))
10
10
import Data.List (foldl' )
11
11
import qualified Data.Map as M
@@ -15,13 +15,16 @@ import Data.Maybe (fromMaybe)
15
15
import Data.Functor ((<$) )
16
16
import Data.Coerce
17
17
import Prelude hiding (lookup )
18
+ import Utils.Containers.Internal.StrictPair
18
19
19
20
main = do
20
21
let m = M. fromAscList elems :: M. Map Int Int
21
22
m_even = M. fromAscList elems_even :: M. Map Int Int
22
23
m_odd = M. fromAscList elems_odd :: M. Map Int Int
24
+ m_odd_keys = M. keysSet m_odd
23
25
evaluate $ rnf [m, m_even, m_odd]
24
26
evaluate $ rnf elems_rev
27
+ evaluate $ rnf m_odd_keys
25
28
defaultMain
26
29
[ bench " lookup absent" $ whnf (lookup evens) m_odd
27
30
, bench " lookup present" $ whnf (lookup evens) m_even
@@ -95,6 +98,12 @@ main = do
95
98
, bench " fromDistinctDescList" $ whnf M. fromDistinctDescList elems_rev
96
99
, bench " fromDistinctDescList:fusion" $ whnf (\ n -> M. fromDistinctDescList [(i,i) | i <- [n,n- 1 .. 1 ]]) bound
97
100
, 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 ])
101
+
102
+ , bench " restrictKeys+withoutKeys"
103
+ $ whnf (\ ks -> M. restrictKeys m ks :*: M. withoutKeys m ks) m_odd_keys
104
+ , bcompare " /restrictKeys+withoutKeys/"
105
+ $ bench " partitionKeys"
106
+ $ whnf (M. partitionKeys m) m_odd_keys
98
107
]
99
108
where
100
109
bound = 2 ^ 12
0 commit comments