git.iko.soy/typeable/pandoc
on master help sign in
Use tasty-bench instead of criterion for benchmarks.
fe06437John MacFarlane
@@ -6,6 +6,7 @@ RESOLVER?=lts-13
6GHCOPTS=-fdiagnostics-color=always
6GHCOPTS=-fdiagnostics-color=always
7WEBSITE=../../web/pandoc.org
7WEBSITE=../../web/pandoc.org
8REVISION?=1
8REVISION?=1
9+BENCHARGS?="--timeout=6"
9
10
10quick:
11quick:
11 stack install --ghc-options='$(GHCOPTS)' --install-ghc --flag 'pandoc:embed_data_files' --fast --test --ghc-options='-j +RTS -A64m -RTS' --test-arguments='-j4 --hide-successes $(TESTARGS)'
12 stack install --ghc-options='$(GHCOPTS)' --install-ghc --flag 'pandoc:embed_data_files' --fast --test --ghc-options='-j +RTS -A64m -RTS' --test-arguments='-j4 --hide-successes $(TESTARGS)'
benchmark/benchmark-pandoc.hs+14−11
@@ -24,8 +24,8 @@ import Control.Monad.Except (throwError, liftIO)
24import qualified Text.Pandoc.UTF8 as UTF8
24import qualified Text.Pandoc.UTF8 as UTF8
25import qualified Data.ByteString as B
25import qualified Data.ByteString as B
26import qualified Data.Text as T
26import qualified Data.Text as T
27−import Criterion.Main
27+import Test.Tasty.Bench
28−import Criterion.Types (Config(..))
28+import Test.Tasty (withResource)
29import Data.List (intersect)
29import Data.List (intersect)
30import Data.Maybe (mapMaybe, catMaybes)
30import Data.Maybe (mapMaybe, catMaybes)
31import System.Environment (getArgs)
31import System.Environment (getArgs)
@@ -59,7 +59,7 @@ readerBench doc name = do
59 <> name
59 <> name
60 return $ case res of
60 return $ case res of
61 Right (readerFun, inp) ->
61 Right (readerFun, inp) ->
62− Just $ bench (T.unpack $ name <> " reader")
62+ Just $ bench (T.unpack name)
63 $ nf (\i -> either (error . show) id $ runPure (readerFun i))
63 $ nf (\i -> either (error . show) id $ runPure (readerFun i))
64 inp
64 inp
65 Left _ -> Nothing
65 Left _ -> Nothing
@@ -71,18 +71,18 @@ getImages = do
71 return [("lalune.jpg", "image/jpg", ll)
71 return [("lalune.jpg", "image/jpg", ll)
72 ,("movie.jpg", "image/jpg", mv)]
72 ,("movie.jpg", "image/jpg", mv)]
73
73
74+writerBench :: [(FilePath, MimeType, BL.ByteString)]
74−writerBench :: Pandoc
75+ -> Pandoc
75 -> T.Text
76 -> T.Text
76 -> Maybe Benchmark
77 -> Maybe Benchmark
77−writerBench doc name =
78+writerBench imgs doc name =
78 case res of
79 case res of
79 Right writerFun ->
80 Right writerFun ->
80− Just $ env getImages $ \imgs ->
81− bench (T.unpack $ name <> " writer")
81+ Just $ bench (T.unpack name)
82 $ nf (\d -> either (error . show) id $
82 $ nf (\d -> either (error . show) id $
83 runPure (do mapM_
83 runPure (do mapM_
84 (\(fp, mt, bs) ->
84 (\(fp, mt, bs) ->
85− insertMedia fp (Just mt) bs)
85+ insertMedia fp (Just mt) bs)
86 imgs
86 imgs
87 writerFun d)) doc
87 writerFun d)) doc
88 Left _ -> Nothing
88 Left _ -> Nothing
@@ -117,6 +117,9 @@ main = do
117 (matchedReaders `intersect` allWriters)
117 (matchedReaders `intersect` allWriters)
118 -- we need the corresponding writer to generate
118 -- we need the corresponding writer to generate
119 -- input for the reader
119 -- input for the reader
120+ imgs <- getImages
120− let writerBs = mapMaybe (writerBench doc) matchedWriters
121+ let writerBs = mapMaybe (writerBench imgs doc) matchedWriters
121− defaultMainWith defaultConfig{ timeLimit = 6.0 }
122+ defaultMain
123+ [ bgroup "writers" writerBs
122− (writerBs ++ readerBs)
124+ , bgroup "readers" readerBs
125+ ]
pandoc.cabal+2−1
@@ -880,7 +880,8 @@ benchmark benchmark-pandoc
880 base >= 4.8 && < 5,
880 base >= 4.8 && < 5,
881 bytestring,
881 bytestring,
882 containers,
882 containers,
883− criterion >= 1.0 && < 1.6,
883+ tasty,
884+ tasty-bench >= 0.1 && <= 0.2,
884 mtl >= 2.2 && < 2.3,
885 mtl >= 2.2 && < 2.3,
885 text >= 1.1.1.0 && < 1.3,
886 text >= 1.1.1.0 && < 1.3,
886 time
887 time
stack.yaml+1
@@ -18,6 +18,7 @@ extra-deps:
18- commonmark-pandoc-0.2.0.1
18- commonmark-pandoc-0.2.0.1
19- doctemplates-0.9
19- doctemplates-0.9
20- texmath-0.12.1
20- texmath-0.12.1
21+- tasty-bench-0.1
21# - citeproc-0.3.0.5
22# - citeproc-0.3.0.5
22- citeproc:
23- citeproc:
23 git: https://github.com/jgm/citeproc.git
24 git: https://github.com/jgm/citeproc.git