Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add a script: how to compile for criterion

  • Loading branch information...
commit be55c8d31600b1721b81bea7f6ebc59684a65525 1 parent dc8deae
@ozgurakgun authored
Showing with 7 additions and 6 deletions.
  1. +5 −6 KnotBinTree.hs
  2. +2 −0  compile.sh
View
11 KnotBinTree.hs
@@ -105,8 +105,8 @@ 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)
@@ -114,10 +114,9 @@ main = do
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
2  compile.sh
@@ -0,0 +1,2 @@
+
+ghc KnotBinTree.hs -main-is KnotBinTree.runCriterion
Please sign in to comment.
Something went wrong with that request. Please try again.