git.iko.soy/typeable/pandoc
on master help sign in
Use tasty-bench instead of criterion for benchmarks.

It is much lighter-weight.

commitfe06437ba4ef12782078ac05c6f9c917f32d51f0 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 30 Jan 2021, 18:01 (6 years ago) parenta6c7469
4 files changed+18−12
Makefile+1 benchmark/benchmark-pandoc.hs+14−11 pandoc.cabal+2−1 stack.yaml+1
Makefile+1
@@ -6,6 +6,7 @@ RESOLVER?=lts-13
66GHCOPTS=-fdiagnostics-color=always
77WEBSITE=../../web/pandoc.org
88REVISION?=1
9+BENCHARGS?="--timeout=6"
910
1011quick:
1112 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)
2424import qualified Text.Pandoc.UTF8 as UTF8
2525import qualified Data.ByteString as B
2626import qualified Data.Text as T
27−import Criterion.Main
28−import Criterion.Types (Config(..))
27+import Test.Tasty.Bench
28+import Test.Tasty (withResource)
2929import Data.List (intersect)
3030import Data.Maybe (mapMaybe, catMaybes)
3131import System.Environment (getArgs)
@@ -59,7 +59,7 @@ readerBench doc name = do
5959 <> name
6060 return $ case res of
6161 Right (readerFun, inp) ->
62− Just $ bench (T.unpack $ name <> " reader")
62+ Just $ bench (T.unpack name)
6363 $ nf (\i -> either (error . show) id $ runPure (readerFun i))
6464 inp
6565 Left _ -> Nothing
@@ -71,18 +71,18 @@ getImages = do
7171 return [("lalune.jpg", "image/jpg", ll)
7272 ,("movie.jpg", "image/jpg", mv)]
7373
74−writerBench :: Pandoc
74+writerBench :: [(FilePath, MimeType, BL.ByteString)]
75+ -> Pandoc
7576 -> T.Text
7677 -> Maybe Benchmark
77−writerBench doc name =
78+writerBench imgs doc name =
7879 case res of
7980 Right writerFun ->
80− Just $ env getImages $ \imgs ->
81− bench (T.unpack $ name <> " writer")
81+ Just $ bench (T.unpack name)
8282 $ nf (\d -> either (error . show) id $
8383 runPure (do mapM_
8484 (\(fp, mt, bs) ->
85− insertMedia fp (Just mt) bs)
85+ insertMedia fp (Just mt) bs)
8686 imgs
8787 writerFun d)) doc
8888 Left _ -> Nothing
@@ -117,6 +117,9 @@ main = do
117117 (matchedReaders `intersect` allWriters)
118118 -- we need the corresponding writer to generate
119119 -- input for the reader
120− let writerBs = mapMaybe (writerBench doc) matchedWriters
121− defaultMainWith defaultConfig{ timeLimit = 6.0 }
122− (writerBs ++ readerBs)
120+ imgs <- getImages
121+ let writerBs = mapMaybe (writerBench imgs doc) matchedWriters
122+ defaultMain
123+ [ bgroup "writers" writerBs
124+ , bgroup "readers" readerBs
125+ ]
pandoc.cabal+2−1
@@ -880,7 +880,8 @@ benchmark benchmark-pandoc
880880 base >= 4.8 && < 5,
881881 bytestring,
882882 containers,
883− criterion >= 1.0 && < 1.6,
883+ tasty,
884+ tasty-bench >= 0.1 && <= 0.2,
884885 mtl >= 2.2 && < 2.3,
885886 text >= 1.1.1.0 && < 1.3,
886887 time
stack.yaml+1
@@ -18,6 +18,7 @@ extra-deps:
1818- commonmark-pandoc-0.2.0.1
1919- doctemplates-0.9
2020- texmath-0.12.1
21+- tasty-bench-0.1
2122# - citeproc-0.3.0.5
2223- citeproc:
2324 git: https://github.com/jgm/citeproc.git