Skip to content

Commit 9c23fbc

Browse files
committed
Add benchmark for Removing by Indexing
1 parent 4a0ebb1 commit 9c23fbc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Time.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ data Min = forall f. NFData (f Int) => Min String (f Int) (f Int -> Int)
2222
data Max = forall f. NFData (f Int) => Max String (f Int) (f Int -> Int)
2323
data Sort = forall f. NFData (f Int) => Sort String (f Int) (f Int -> f Int)
2424
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)
2526

2627
main :: IO ()
2728
main = do
@@ -94,6 +95,12 @@ main = do
9495
, RemoveElement "Data.Vector.Unboxed" uvector (UV.filter)
9596
, RemoveElement "Data.Sequence" seqd (S.filter)
9697
])
98+
, bgroup
99+
"Remove By Index"
100+
(removeByIndexes
101+
[ RemoveByIndex "Data.Vector" vector (V.ifilter)
102+
, RemoveByIndex "Data.Vector.Unboxed" uvector (UV.ifilter)
103+
])
97104
]
98105
where
99106
conses funcs =
@@ -132,6 +139,12 @@ main = do
132139
| relem <- [1, 100, 1000, 10000 :: Int]
133140
, RemoveElement title payload func <- funcs
134141
]
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+
135148
sampleList :: IO [Int]
136149
sampleList = evaluate $ force [1 .. 10005]
137150
sampleVector :: IO (V.Vector Int)

0 commit comments

Comments
 (0)