add a hash-table benchmark
authorSimon Marlow <marlowsd@gmail.com>
Wed, 30 Dec 2009 16:48:22 +0000 (16:48 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 30 Dec 2009 16:48:22 +0000 (16:48 +0000)
gc/hash/Makefile [new file with mode: 0644]
gc/hash/hash.hs [new file with mode: 0644]

diff --git a/gc/hash/Makefile b/gc/hash/Makefile
new file mode 100644 (file)
index 0000000..2b30d8c
--- /dev/null
@@ -0,0 +1,12 @@
+TOP = ../..
+include $(TOP)/mk/boilerplate.mk
+
+FAST_OPTS = 1000000
+NORM_OPTS = 10000000
+SLOW_OPTS = 100000000
+
+ifeq "$(HEAP)" "LARGE"
+SRC_RUNTEST_OPTS += +RTS -H430m -RTS
+endif
+
+include $(TOP)/mk/target.mk
diff --git a/gc/hash/hash.hs b/gc/hash/hash.hs
new file mode 100644 (file)
index 0000000..a15848d
--- /dev/null
@@ -0,0 +1,10 @@
+import Control.Monad
+import qualified Data.HashTable as H
+import System.Environment
+
+main = do
+  [size] <- fmap (fmap read) getArgs
+  m <- H.new (==) H.hashInt
+  forM_ [1..size] $ \n -> H.insert m n n
+  v <- H.lookup m 100
+  print v