on master help sign in
Make benchmarks.
3e973aeBryan O'Sullivan
tests/Benchmarks.hs+8−5
@@ -3,8 +3,8 @@
3import qualified Data.ByteString.Char8 as BS
3import qualified Data.ByteString.Char8 as BS
4import qualified Data.ByteString.Lazy.Char8 as BL
4import qualified Data.ByteString.Lazy.Char8 as BL
5import qualified Data.ByteString.Lazy.Internal as BL
5import qualified Data.ByteString.Lazy.Internal as BL
6+import Control.Monad.Trans (liftIO)
6import Control.Exception (evaluate)
7import Control.Exception (evaluate)
7−import Control.DeepSeq (NFData(..))
8import Control.Parallel.Strategies
8import Control.Parallel.Strategies
9import Criterion.Main
9import Criterion.Main
10import Data.Char
10import Data.Char
@@ -60,10 +60,13 @@ main = do
60 tsl = TS.lines tsa
60 tsl = TS.lines tsa
61 tll = TL.lines tla
61 tll = TL.lines tla
62 ll = L.lines la
62 ll = L.lines la
63+ defaultMainWith
64+ myConfig
65+ (liftIO . evaluate $
63− evaluate (rnf [B tsa, B tsb, B tla, B tlb, B bsa, B bsb, B bla, B blb,
66+ rnf [B tsa, B tsb, B tla, B tlb, B bsa, B bsb, B bla, B blb,
64− B bsa_len, B tsa_len, B bla_len, B tla_len, B la, B la_len,
67+ B bsa_len, B tsa_len, B bla_len, B tla_len, B la, B la_len,
65− B tsb_len, B lb, B bsl, B bll, B tsl, B tll, B ll])
68+ B tsb_len, B lb, B bsl, B bll, B tsl, B tll, B ll])
66− defaultMainWith myConfig [
69+ [
67 bgroup "append" [
70 bgroup "append" [
68 bench "ts" $ nf (TS.append tsb) tsa
71 bench "ts" $ nf (TS.append tsb) tsa
69 , bench "tl" $ nf (TL.append tlb) tla
72 , bench "tl" $ nf (TL.append tlb) tla
tests/Makefile+7−2
@@ -15,7 +15,7 @@ lib-srcs := $(shell grep '^ *Data' ../text.cabal | \
15
15
16cabal := $(shell which cabal 2>/dev/null)
16cabal := $(shell which cabal 2>/dev/null)
17
17
18−all: qc coverage
18+all: bm qc coverage
19
19
20lib: $(lib)
20lib: $(lib)
21
21
@@ -52,6 +52,11 @@ qc-hpc-html/hpc_index.html: qc-hpc
52 --exclude=Data.Text.Fusion.CaseMapping \
52 --exclude=Data.Text.Fusion.CaseMapping \
53 --exclude=QuickCheckUtils --srcdir=.. --srcdir=. --destdir=$(dir $@)
53 --exclude=QuickCheckUtils --srcdir=.. --srcdir=. --destdir=$(dir $@)
54
54
55+Benchmarks.o: ghc-opt-flags = -O
56+bm Benchmarks.o: ghc-flags += -hide-package transformers -package utf8-string
57+bm: Benchmarks.o
58+ $(ghc) $(ghc-flags) -o $@ $^ $(lib)
59+
55SlowFunctions.o: ghc-opt-flags = -O2
60SlowFunctions.o: ghc-opt-flags = -O2
56SearchBench.o: ghc-opt-flags = -O
61SearchBench.o: ghc-opt-flags = -O
57%.o: %.hs
62%.o: %.hs
@@ -67,4 +72,4 @@ text-testdata.tar.bz2:
67 curl -O http://projects.haskell.org/text/text-testdata.tar.bz2
72 curl -O http://projects.haskell.org/text/text-testdata.tar.bz2
68
73
69clean:
74clean:
70− -rm -rf *.o *.hi *.tix qc qc-hpc hpcdir .hpc qc-hpc-html
75+ -rm -rf *.o *.hi *.tix bm qc qc-hpc hpcdir .hpc qc-hpc-html