Integrated benchmark into cabal.

Can now do:

cabal configure --enable-benchmarks && cabal build
cabal bench --benchmark-option='markdown' --benchmark-option='-s 20'
This commit is contained in:
John MacFarlane 2012-07-26 09:18:17 -07:00
parent 45e4c123a4
commit c414a08bcf
2 changed files with 21 additions and 4 deletions

View file

@ -3,7 +3,6 @@ import Text.Pandoc.Shared (readDataFile, normalize)
import Criterion.Main
import Data.List (isSuffixOf)
import Text.JSON.Generic
import Data.Default
readerBench :: Pandoc
-> (String, ReaderOptions -> String -> Pandoc)
@ -42,5 +41,6 @@ main = do
let doc = readMarkdown opts inp
let readerBs = map (readerBench doc) readers
let writers' = [(n,w) | (n, PureStringWriter w) <- writers]
defaultMain $ map (writerBench doc) writers' ++ readerBs ++ normalizeBench doc
defaultMain $
map (writerBench doc) writers' ++ readerBs ++ normalizeBench doc

View file

@ -96,8 +96,6 @@ Extra-Source-Files:
-- generated man pages (produced post-build)
man/man1/pandoc.1,
man/man5/pandoc_markdown.5,
-- benchmarks
Benchmark.hs,
-- tests
tests/bodybg.gif,
tests/docbook-reader.docbook
@ -427,3 +425,22 @@ Executable test-pandoc
Default-Language: Haskell98
Default-Extensions: CPP, TemplateHaskell, QuasiQuotes
benchmark benchmark-pandoc
Type: exitcode-stdio-1.0
Main-Is: benchmark-pandoc.hs
Hs-Source-Dirs: benchmark
if impl(ghc >= 6.10)
Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
else
Build-depends: base >= 3 && < 4
Build-Depends: pandoc,
criterion >= 0.5 && < 0.7,
json >= 0.4 && < 0.6
if impl(ghc >= 7.0.1)
Ghc-Options: -O2 -rtsopts -Wall -fno-warn-unused-do-bind -dno-debug-output
else
if impl(ghc >= 6.12)
Ghc-Options: -O2 -Wall -fno-warn-unused-do-bind -dno-debug-output
else
Ghc-Options: -O2 -Wall
Default-Language: Haskell98