aboutsummaryrefslogtreecommitdiff
path: root/benchmark
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 /benchmark
parenta6c7469c85a6239c0148b3dab0b6bb52ce1fe85d (diff)
downloadpandoc-fe06437ba4ef12782078ac05c6f9c917f32d51f0.tar.gz
Use tasty-bench instead of criterion for benchmarks.
It is much lighter-weight.
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/benchmark-pandoc.hs25
1 files changed, 14 insertions, 11 deletions
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
+ ]