5
5
6
6
module Main (main ) where
7
7
8
- import Common
8
+ import Common ()
9
9
import Control.Arrow
10
10
import Control.DeepSeq
11
11
import Control.Monad
@@ -19,7 +19,6 @@ import qualified Data.HashTable.Class
19
19
import qualified Data.HashTable.IO
20
20
import qualified Data.IntMap.Lazy
21
21
import qualified Data.IntMap.Strict
22
- import qualified Data.Judy
23
22
import qualified Data.Map.Lazy
24
23
import qualified Data.Map.Strict
25
24
import Data.Maybe (isJust )
@@ -96,7 +95,6 @@ main = do
96
95
" Data.HashTable.IO.CuckooHashTable"
97
96
Data.HashTable.IO. new
98
97
insertHashTableIOCuckoo
99
- , InsertIntIO " Data.Judy" Data.Judy. new insertJudy
100
98
])
101
99
, bgroup
102
100
" Intersection (Randomized)"
@@ -141,7 +139,7 @@ main = do
141
139
" Data.HashTable.IO.CuckooHashTable"
142
140
Data.HashTable.IO. fromList
143
141
intersectionHashTableIOCuckoo
144
- , IntersectionIO " Data.Judy " judyFromList intersectionJudy
142
+
145
143
])
146
144
, bgroup
147
145
" Lookup Int (Randomized)"
@@ -183,7 +181,7 @@ main = do
183
181
" Data.HashTable.IO.CuckooHashTable"
184
182
(Data.HashTable.IO. fromList :: [(Int , Int )] -> IO (Data.HashTable.IO. CuckooHashTable Int Int ))
185
183
Data.HashTable.IO. lookup
186
- , LookupIO " Data.Judy " judyFromList judyLookup
184
+
187
185
])
188
186
, bgroup
189
187
" FromList ByteString (Monotonic)"
@@ -251,7 +249,7 @@ main = do
251
249
[ env
252
250
(let ! elems =
253
251
force (zip (randoms (mkStdGen 0 ) :: [Int ]) [1 :: Int .. i ])
254
- in pure elems)
252
+ in pure elems)
255
253
(\ _ -> bench (title ++ " :" ++ show i) $ nf func i)
256
254
| i <- [10 , 100 , 1000 , 10000 ]
257
255
, InsertInt title func <- funcs
@@ -267,7 +265,7 @@ main = do
267
265
force
268
266
( build (zip (randoms (mkStdGen 0 ) :: [Int ]) [1 :: Int .. i ])
269
267
, build (zip (randoms (mkStdGen 1 ) :: [Int ]) [1 :: Int .. i ]))
270
- in pure args)
268
+ in pure args)
271
269
(\ args -> bench (title ++ " :" ++ show i) $ nf (uncurry intersect) args)
272
270
| i <- [10 , 100 , 1000 , 10000 , 100000 , 1000000 ]
273
271
, Intersection title build intersect <- funcs
@@ -288,7 +286,7 @@ main = do
288
286
(map
289
287
(first (S8. pack . show ))
290
288
(take i (zip (randoms (mkStdGen 0 ) :: [Int ]) [1 .. ])))
291
- in pure elems)
289
+ in pure elems)
292
290
(\ elems -> bench (title ++ " :" ++ show i) $ nf func elems)
293
291
| i <- [10 , 100 , 1000 , 10000 ]
294
292
, FromListBS title func <- funcs
@@ -298,7 +296,7 @@ main = do
298
296
(let list = take i (zip (randoms (mkStdGen 0 ) :: [Int ]) [1 .. ])
299
297
(! key, _) = list !! (div i 2 )
300
298
! elems = force (fromList list)
301
- in pure (elems, key))
299
+ in pure (elems, key))
302
300
(\ (~ (elems, key)) ->
303
301
bench (title ++ " :" ++ show i) $ nf (flip func elems) key)
304
302
| i <- [10 , 100 , 1000 , 10000 , 100000 , 1000000 ]
@@ -313,7 +311,7 @@ main = do
313
311
(take i (zip [1 :: Int .. ] [1 .. ])))
314
312
(! key, _) = list !! (div i 2 )
315
313
! elems = force (fromList list)
316
- in pure (elems, key))
314
+ in pure (elems, key))
317
315
(\ (~ (elems, key)) ->
318
316
bench (title ++ " :" ++ show i) $ nf (flip func elems) key)
319
317
| i <- [10000 ]
@@ -328,7 +326,7 @@ main = do
328
326
(take i (zip (randoms (mkStdGen 0 ) :: [Int ]) [1 .. ])))
329
327
(! key, _) = list !! (div i 2 )
330
328
! elems = force (fromList list)
331
- in pure (elems, key))
329
+ in pure (elems, key))
332
330
(\ (~ (elems, key)) ->
333
331
bench (title ++ " :" ++ show i) $ nf (flip func elems) key)
334
332
| i <- [10000 ]
@@ -338,8 +336,8 @@ main = do
338
336
[ env
339
337
(let list = take i (zip (randoms (mkStdGen 0 ) :: [Int ]) [1 .. ])
340
338
(! key, _) = list !! (div i 2 )
341
- in do ! elems <- fmap force (fromList list)
342
- pure (elems, key))
339
+ in do ! elems <- fmap force (fromList list)
340
+ pure (elems, key))
343
341
(\ (~ (elems, key)) ->
344
342
bench (title ++ " :" ++ show i) $ nfIO (func elems key))
345
343
| i <- [10 , 100 , 1000 , 10000 , 100000 , 1000000 ]
@@ -352,7 +350,7 @@ main = do
352
350
(map
353
351
(first (S8. pack . show ))
354
352
(take i (zip [1 :: Int .. ] [1 .. ])))
355
- in pure elems)
353
+ in pure elems)
356
354
(\ elems -> bench (title ++ " :" ++ show i) $ nf func elems)
357
355
| i <- [10000 ]
358
356
, FromListBS title func <- funcs
@@ -420,24 +418,6 @@ insertHashTableIOLinear :: Data.HashTable.IO.LinearHashTable Int Int
420
418
-> IO (Data.HashTable.IO. LinearHashTable Int Int )
421
419
insertHashTableIOLinear = insertHashTableIO
422
420
423
- insertJudy :: Data.Judy. JudyL Int -> Int -> IO (Data.Judy. JudyL Int )
424
- insertJudy j n0 = do
425
- mapM_ (\ n -> Data.Judy. insert (fromIntegral n) n j) [1 .. n0]
426
- return j
427
-
428
- judyLookup :: Data.Judy. JudyL Int -> Int -> IO (Maybe Int )
429
- judyLookup j k = Data.Judy. lookup (fromIntegral k) j
430
-
431
- intersectionJudy :: Data.Judy. JudyL Int -> Data.Judy. JudyL Int -> IO (Data.Judy. JudyL Int )
432
- intersectionJudy ij0 ij1 = do
433
- j <- Data.Judy. new
434
- j0 <- Data.Judy. freeze ij0
435
- j0Kvs <- Data.Judy. toList j0
436
- mapM_ (\ (k,v) ->
437
- Data.Judy. member k ij1
438
- >>= \ found -> when found (Data.Judy. insert k v j)) j0Kvs
439
- return j
440
-
441
421
intersectionHashTableIO :: Data.HashTable.Class. HashTable ht
442
422
=> Data.HashTable.IO. IOHashTable ht Int Int
443
423
-> Data.HashTable.IO. IOHashTable ht Int Int
0 commit comments