Permalink
Browse files

add a script: how to compile for criterion

  • Loading branch information...
1 parent dc8deae commit be55c8d31600b1721b81bea7f6ebc59684a65525 @ozgurakgun committed Apr 14, 2012
Showing with 7 additions and 6 deletions.
  1. +5 −6 KnotBinTree.hs
  2. +2 −0 compile.sh
View
@@ -105,19 +105,18 @@ qcAll = do
quickCheck ( prop_insertMember :: Int -> (Int,[Int]) -> Bool )
quickCheck ( prop_pathTos :: Int -> (Int,[Int]) -> Bool )
-main :: IO ()
-main = do
+runCriterion :: IO ()
+runCriterion = do
let
rand :: IO Int
rand = getRandomR (0,10000)
nb :: Int
nb = 10000
- top <- rand
- stuff <- sequence $ replicate nb rand
- needles <- map (stuff!!) <$> sequence (replicate 5 $ getRandomR (0,nb-1))
- let tree = fromList (top,stuff)
+ (top:stuff) <- sequence $ replicate nb rand
+ let tree = fromList (top,stuff)
+ needles <- map (stuff!!) <$> sequence (replicate 5 $ getRandomR (0,nb-1))
deepseq (needles,tree) $ defaultMain $ concat
[ [ bench ("pathTo' " ++ show needle) $ nf (uncurry pathTo') (needle,tree)
, bench ("pathTo " ++ show needle) $ nf (uncurry pathTo ) (needle,tree)
View
@@ -0,0 +1,2 @@
+
+ghc KnotBinTree.hs -main-is KnotBinTree.runCriterion

0 comments on commit be55c8d

Please sign in to comment.