aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-01-30 18:01:14 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-01-30 18:01:14 -0800
commitfe06437ba4ef12782078ac05c6f9c917f32d51f0 (patch)
treeac094e01e627f48b3356daad71a7bff363f9c0bb
parenta6c7469c85a6239c0148b3dab0b6bb52ce1fe85d (diff)
downloadpandoc-fe06437ba4ef12782078ac05c6f9c917f32d51f0.tar.gz
Use tasty-bench instead of criterion for benchmarks.
It is much lighter-weight.
-rw-r--r--Makefile1
-rw-r--r--benchmark/benchmark-pandoc.hs25
-rw-r--r--pandoc.cabal3
-rw-r--r--stack.yaml1
4 files changed, 18 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index f27272b08..1985a4810 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ RESOLVER?=lts-13
GHCOPTS=-fdiagnostics-color=always
WEBSITE=../../web/pandoc.org
REVISION?=1
+BENCHARGS?="--timeout=6"
quick:
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)'
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs
index b3e67bb14..2e7600cbc 100644
--- a/benchmark/benchmark-pandoc.hs
+++ b/benchmark/benchmark-pandoc.hs
@@ -24,8 +24,8 @@ import Control.Monad.Except (throwError, liftIO)
import qualified Text.Pandoc.UTF8 as UTF8
import qualified Data.ByteString as B
import qualified Data.Text as T
-import Criterion.Main
-import Criterion.Types (Config(..))
+import Test.Tasty.Bench
+import Test.Tasty (withResource)
import Data.List (intersect)
import Data.Maybe (mapMaybe, catMaybes)
import System.Environment (getArgs)
@@ -59,7 +59,7 @@ readerBench doc name = do
<> name
return $ case res of
Right (readerFun, inp) ->
- Just $ bench (T.unpack $ name <> " reader")
+ Just $ bench (T.unpack name)
$ nf (\i -> either (error . show) id $ runPure (readerFun i))
inp
Left _ -> Nothing
@@ -71,18 +71,18 @@ getImages = do
return [("lalune.jpg", "image/jpg", ll)
,("movie.jpg", "image/jpg", mv)]
-writerBench :: Pandoc
+writerBench :: [(FilePath, MimeType, BL.ByteString)]
+ -> Pandoc
-> T.Text
-> Maybe Benchmark
-writerBench doc name =
+writerBench imgs doc name =
case res of
Right writerFun ->
- Just $ env getImages $ \imgs ->
- bench (T.unpack $ name <> " writer")
+ Just $ bench (T.unpack name)
$ nf (\d -> either (error . show) id $
runPure (do mapM_
(\(fp, mt, bs) ->
- insertMedia fp (Just mt) bs)
+ insertMedia fp (Just mt) bs)
imgs
writerFun d)) doc
Left _ -> Nothing
@@ -117,6 +117,9 @@ main = do
(matchedReaders `intersect` allWriters)
-- we need the corresponding writer to generate
-- input for the reader
- let writerBs = mapMaybe (writerBench doc) matchedWriters
- defaultMainWith defaultConfig{ timeLimit = 6.0 }
- (writerBs ++ readerBs)
+ imgs <- getImages
+ let writerBs = mapMaybe (writerBench imgs doc) matchedWriters
+ defaultMain
+ [ bgroup "writers" writerBs
+ , bgroup "readers" readerBs
+ ]
diff --git a/pandoc.cabal b/pandoc.cabal
index f7d48372b..6c8254616 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -880,7 +880,8 @@ benchmark benchmark-pandoc
base >= 4.8 && < 5,
bytestring,
containers,
- criterion >= 1.0 && < 1.6,
+ tasty,
+ tasty-bench >= 0.1 && <= 0.2,
mtl >= 2.2 && < 2.3,
text >= 1.1.1.0 && < 1.3,
time
diff --git a/stack.yaml b/stack.yaml
index 5ef814487..85022e91d 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -18,6 +18,7 @@ extra-deps:
- commonmark-pandoc-0.2.0.1
- doctemplates-0.9
- texmath-0.12.1
+- tasty-bench-0.1
# - citeproc-0.3.0.5
- citeproc:
git: https://github.com/jgm/citeproc.git