Permalink
Browse files

Playing with benchmark

  • Loading branch information...
1 parent 1a73dca commit 93544bd04663f29843c39b27a0b4c3f094d94b28 @mightybyte mightybyte committed Oct 2, 2012
Showing with 60 additions and 73 deletions.
  1. +0 −55 heist.cabal
  2. +55 −0 test/heist-testsuite.cabal
  3. +4 −18 test/suite/Benchmark.hs
  4. +1 −0 test/templates/backslash.tpl
View
@@ -186,58 +186,3 @@ source-repository head
type: git
location: https://github.com/snapframework/heist.git
--- Executable benchmark
--- hs-source-dirs: src test/suite
--- main-is: Benchmark.hs
---
--- build-depends:
--- MonadCatchIO-transformers >= 0.3 && < 0.4,
--- HUnit >= 1.2 && < 1.3,
--- criterion >= 0.6 && < 0.7,
--- test-framework >= 0.4 && < 0.7,
--- test-framework-hunit >= 0.2 && < 0.3,
---
--- -- Copied from regular dependencies:
---
--- aeson >= 0.6 && < 0.7,
--- attoparsec >= 0.10 && < 0.11,
--- base >= 4 && < 5,
--- blaze-builder >= 0.2 && < 0.4,
--- blaze-html >= 0.4 && < 0.6,
--- blaze-markup >= 0.5 && < 0.6,
--- bytestring >= 0.9 && < 0.11,
--- containers >= 0.2 && < 0.6,
--- directory >= 1.1 && < 1.2,
--- directory-tree >= 0.10 && < 0.11,
--- dlist >= 0.5 && < 0.6,
--- errors >= 1.3 && < 1.4,
--- filepath >= 1.3 && < 1.4,
--- hashable >= 1.1 && < 1.2,
--- MonadCatchIO-transformers >= 0.2.1 && < 0.4,
--- mtl >= 2.0 && < 2.2,
--- process >= 1.1 && < 1.2,
--- random >= 1.0 && < 1.1,
--- text >= 0.10 && < 0.12,
--- time >= 1.1 && < 1.5,
--- transformers >= 0.2 && < 0.4,
--- xmlhtml >= 0.1.6 && < 0.3,
--- unordered-containers >= 0.1.4 && < 0.3,
--- vector >= 0.9 && < 0.10
---
--- ghc-options: -O2 -Wall -fwarn-tabs -funbox-strict-fields -threaded
--- -fno-warn-unused-do-bind -rtsopts
---
--- ghc-prof-options: -prof -auto-all
---
--- Extensions:
--- GeneralizedNewtypeDeriving,
--- PackageImports,
--- ScopedTypeVariables,
--- DeriveDataTypeable,
--- FlexibleInstances,
--- MultiParamTypeClasses,
--- UndecidableInstances,
--- OverloadedStrings,
--- TypeSynonymInstances,
--- NoMonomorphismRestriction
-
View
@@ -41,3 +41,58 @@ Executable testsuite
ghc-options: -O2 -Wall -fhpc -fwarn-tabs -funbox-strict-fields -threaded
Extensions: OverloadedStrings
+Executable benchmark
+ hs-source-dirs: ../src suite
+ main-is: Benchmark.hs
+
+ build-depends:
+ MonadCatchIO-transformers >= 0.3 && < 0.4,
+ HUnit >= 1.2 && < 1.3,
+ criterion >= 0.6 && < 0.7,
+ test-framework >= 0.4 && < 0.7,
+ test-framework-hunit >= 0.2 && < 0.3,
+
+ -- Copied from regular dependencies:
+
+ aeson >= 0.6 && < 0.7,
+ attoparsec >= 0.10 && < 0.11,
+ base >= 4 && < 5,
+ blaze-builder >= 0.2 && < 0.4,
+ blaze-html >= 0.4 && < 0.6,
+ blaze-markup >= 0.5 && < 0.6,
+ bytestring >= 0.9 && < 0.11,
+ containers >= 0.2 && < 0.6,
+ directory >= 1.1 && < 1.2,
+ directory-tree >= 0.10 && < 0.11,
+ dlist >= 0.5 && < 0.6,
+ errors >= 1.3 && < 1.4,
+ filepath >= 1.3 && < 1.4,
+ hashable >= 1.1 && < 1.2,
+ MonadCatchIO-transformers >= 0.2.1 && < 0.4,
+ mtl >= 2.0 && < 2.2,
+ process >= 1.1 && < 1.2,
+ random >= 1.0 && < 1.1,
+ text >= 0.10 && < 0.12,
+ time >= 1.1 && < 1.5,
+ transformers >= 0.2 && < 0.4,
+ xmlhtml >= 0.1.6 && < 0.3,
+ unordered-containers >= 0.1.4 && < 0.3,
+ vector >= 0.9 && < 0.10
+
+ ghc-options: -O2 -Wall -fwarn-tabs -funbox-strict-fields -threaded
+ -fno-warn-unused-do-bind -rtsopts
+
+ ghc-prof-options: -prof -auto-all
+
+ Extensions:
+ GeneralizedNewtypeDeriving,
+ PackageImports,
+ ScopedTypeVariables,
+ DeriveDataTypeable,
+ FlexibleInstances,
+ MultiParamTypeClasses,
+ UndecidableInstances,
+ OverloadedStrings,
+ TypeSynonymInstances,
+ NoMonomorphismRestriction
+
View
@@ -36,20 +36,7 @@ loadWithCache baseDir = do
initHeistWithCacheTag hc
either (error . unlines) (return . fst) etm
-main = do
- let page = "faq"
- pageStr = T.unpack $ decodeUtf8 page
- dir = "snap-website-nocache"
- hs <- loadWithCache dir
- let !compiledTemplate = fst $! fromJust $! C.renderTemplate hs page
- compiledAction = do
- !res <- compiledTemplate
- return $! toByteString $! res
- out <- compiledAction
- B.writeFile (pageStr++".out.compiled."++dir) $ out
- putStrLn "Templates loaded"
- replicateM_ 1000000 $ whnfIO compiledAction
- putStrLn "done"
+main = justRender "snap-website-nocache"
justRender dir = do
let page = "faq"
@@ -60,6 +47,7 @@ justRender dir = do
res <- compiledTemplate
return $! toByteString $! res
out <- compiledAction
+ putStrLn $ "Rendered ByteString of length "++(show $ B.length out)
B.writeFile (pageStr++".out.compiled."++dir) $ out
defaultMain
@@ -68,9 +56,8 @@ justRender dir = do
------------------------------------------------------------------------------
--applyComparison :: IO ()
-applyComparison dir = do
- let page = "faq"
- pageStr = T.unpack $ decodeUtf8 page
+applyComparison dir page = do
+ let pageStr = T.unpack $ decodeUtf8 page
hs <- loadWithCache dir
let compiledAction = do
res <- fst $ fromJust $ C.renderTemplate hs page
@@ -87,7 +74,6 @@ applyComparison dir = do
defaultMain
[ bench (pageStr++"-compiled") (whnfIO compiledAction)
, bench (pageStr++"-interpreted") (whnfIO interpretedAction)
- , bench "getCurrentTime" (whnfIO getCurrentTime)
]
cmdLineTemplate :: String -> String -> IO ()
@@ -0,0 +1 @@
+<foo regex='\d+\\d'/>

0 comments on commit 93544bd

Please sign in to comment.