Skip to content

Instantly share code, notes, and snippets.

@gregorycollins
Created February 12, 2013 16:25
Show Gist options
  • Save gregorycollins/4771081 to your computer and use it in GitHub Desktop.
Save gregorycollins/4771081 to your computer and use it in GitHub Desktop.
Hashtables benchmark
{-# 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