Commits

Bryan O'Sullivan  committed e18e8b7

Make benchmarks.

  • Participants
  • Parent commits e2d1513

Comments (0)

Files changed (2)

File tests/Benchmarks.hs

 import qualified Data.ByteString.Char8 as BS
 import qualified Data.ByteString.Lazy.Char8 as BL
 import qualified Data.ByteString.Lazy.Internal as BL
+import Control.Monad.Trans (liftIO)
 import Control.Exception (evaluate)
-import Control.DeepSeq (NFData(..))
 import Control.Parallel.Strategies
 import Criterion.Main
 import Data.Char
       tsl     = TS.lines tsa
       tll     = TL.lines tla
       ll      = L.lines la
-  evaluate (rnf [B tsa, B tsb, B tla, B tlb, B bsa, B bsb, B bla, B blb,
-                 B bsa_len, B tsa_len, B bla_len, B tla_len, B la, B la_len,
-                 B tsb_len, B lb, B bsl, B bll, B tsl, B tll, B ll])
-  defaultMainWith myConfig [
+  defaultMainWith
+    myConfig
+    (liftIO . evaluate $
+     rnf [B tsa, B tsb, B tla, B tlb, B bsa, B bsb, B bla, B blb,
+          B bsa_len, B tsa_len, B bla_len, B tla_len, B la, B la_len,
+          B tsb_len, B lb, B bsl, B bll, B tsl, B tll, B ll])
+    [
       bgroup "append" [
         bench "ts" $ nf (TS.append tsb) tsa
       , bench "tl" $ nf (TL.append tlb) tla

File tests/Makefile

 
 cabal := $(shell which cabal 2>/dev/null)
 
-all: qc coverage
+all: bm qc coverage
 
 lib: $(lib)
 
 	  --exclude=Data.Text.Fusion.CaseMapping \
 	  --exclude=QuickCheckUtils --srcdir=.. --srcdir=. --destdir=$(dir $@)
 
+Benchmarks.o: ghc-opt-flags = -O
+bm Benchmarks.o: ghc-flags += -hide-package transformers -package utf8-string
+bm: Benchmarks.o
+	$(ghc) $(ghc-flags) -o $@ $^ $(lib)
+
 SlowFunctions.o: ghc-opt-flags = -O2
 SearchBench.o: ghc-opt-flags = -O
 %.o: %.hs
 	curl -O http://projects.haskell.org/text/text-testdata.tar.bz2
 
 clean:
-	-rm -rf *.o *.hi *.tix qc qc-hpc hpcdir .hpc qc-hpc-html
+	-rm -rf *.o *.hi *.tix bm qc qc-hpc hpcdir .hpc qc-hpc-html