summaryrefslogtreecommitdiff
path: root/space/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'space/Main.hs')
-rw-r--r--space/Main.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/space/Main.hs b/space/Main.hs
new file mode 100644
index 0000000..4e98ece
--- /dev/null
+++ b/space/Main.hs
@@ -0,0 +1,26 @@
+module Main where
+
+import Control.DeepSeq
+import qualified Data.HashTable.IO as H
+import Data.HashTable.IO.Swiss hiding (fildM, mapM_)
+import qualified Data.HashTable.ST.Basic
+import qualified Data.HashTable.ST.Swiss as S
+import Weigh
+
+ssize = 1000000
+
+main =
+ mainWith $ do
+ io "Swiss.insert" (testInsert new insert) ssize
+ io "Data.HashTable.ST.Basic.insert" (testInsert (H.new :: IO (H.BasicHashTable Int Int)) H.insert) ssize
+ io "Swiss.insert sized" (testInsert (newSized (2^21)) insert) ssize
+ io "Data.HashTable.ST.Basic.insert sized" (testInsert (H.newSized (2^21) :: IO (H.BasicHashTable Int Int)) H.insert) ssize
+
+testInsert new insert size = do
+ t <- new
+ mapM_ (\x -> insert t x x) ([1..size] :: [Int])
+ pure t
+
+instance NFData (Data.HashTable.ST.Basic.HashTable s k v) where
+ rnf x = seq x ()
+instance NFData (S.Table s k v)