@@ -22,6 +22,7 @@ data Min = forall f. NFData (f Int) => Min String (f Int) (f Int -> Int)
22
22
data Max = forall f . NFData (f Int ) => Max String (f Int ) (f Int -> Int )
23
23
data Sort = forall f . NFData (f Int ) => Sort String (f Int ) (f Int -> f Int )
24
24
data RemoveElement = forall f . NFData (f Int ) => RemoveElement String (f Int ) ((Int -> Bool ) -> f Int -> f Int )
25
+ data RemoveByIndex = forall f . NFData (f Int ) => RemoveByIndex String (f Int ) ((Int -> Int -> Bool ) -> f Int -> f Int )
25
26
26
27
main :: IO ()
27
28
main = do
@@ -94,6 +95,12 @@ main = do
94
95
, RemoveElement " Data.Vector.Unboxed" uvector (UV. filter )
95
96
, RemoveElement " Data.Sequence" seqd (S. filter )
96
97
])
98
+ , bgroup
99
+ " Remove By Index"
100
+ (removeByIndexes
101
+ [ RemoveByIndex " Data.Vector" vector (V. ifilter)
102
+ , RemoveByIndex " Data.Vector.Unboxed" uvector (UV. ifilter)
103
+ ])
97
104
]
98
105
where
99
106
conses funcs =
@@ -132,6 +139,12 @@ main = do
132
139
| relem <- [1 , 100 , 1000 , 10000 :: Int ]
133
140
, RemoveElement title payload func <- funcs
134
141
]
142
+ removeByIndexes funcs =
143
+ [ bench (title ++ " :" ++ show relem) $ nf (\ x -> func (\ index _ -> index /= relem) x) payload
144
+ | relem <- [1 , 100 , 1000 , 10000 :: Int ]
145
+ , RemoveByIndex title payload func <- funcs
146
+ ]
147
+
135
148
sampleList :: IO [Int ]
136
149
sampleList = evaluate $ force [1 .. 10005 ]
137
150
sampleVector :: IO (V. Vector Int )
0 commit comments