Created
February 12, 2013 16:25
-
-
Save gregorycollins/4771081 to your computer and use it in GitHub Desktop.
Hashtables benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
import Data.Hashable | |
import qualified Data.HashTable.IO as H | |
newtype HInt = HInt Int | |
deriving (Num, Eq, Ord) | |
instance Hashable HInt where | |
hashWithSalt _ (HInt k) = k | |
main :: IO () | |
main = do | |
h <- H.fromListWithSizeHint n [(HInt x,x) | x <- [1..n]] :: IO (H.CuckooHashTable HInt Int) | |
print =<< H.lookup h 100 | |
where | |
n = 10^(7 :: Int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment