Permalink
Browse files

Force bench data before running benchmarks

  • Loading branch information...
1 parent 7504aac commit 769496ca48767cd072882be743bb1dbc8632186a @tibbe tibbe committed Mar 30, 2011
Showing with 15 additions and 2 deletions.
  1. +15 −2 benchmarks/Builder.hs
View
17 benchmarks/Builder.hs
@@ -1,6 +1,11 @@
+{-# LANGUAGE ExistentialQuantification #-}
module Main (main) where
-import Criterion.Main (bench, defaultMain, whnf)
+import Control.DeepSeq
+import Control.Exception (evaluate)
+import Control.Monad.Trans (liftIO)
+import Criterion.Config
+import Criterion.Main hiding (run)
import qualified Data.ByteString as S
import qualified Data.ByteString.Char8 as C
import qualified Data.ByteString.Lazy as L
@@ -10,8 +15,16 @@ import Data.Word (Word8)
import Data.Binary.Builder
+instance NFData S.ByteString
+
+data B = forall a. NFData a => B a
+
+instance NFData B where
+ rnf (B b) = rnf b
+
main :: IO ()
-main = defaultMain
+main = defaultMainWith defaultConfig
+ (liftIO . evaluate $ rnf [B word8s, B smallByteString, B largeByteString])
[ -- Test GHC loop optimization of continuation based code.
bench "[Word8]" $ whnf (run . fromWord8s) word8s

0 comments on commit 769496c

Please sign in to comment.