From ff0fcedcb3c33015f9d550acce8fad2d662d49bd Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 15 Mar 2021 22:50:18 -0700 Subject: Switch to gauge for now for benchmarks. tasty-bench is displaying odd behavior, with different timings depending on the `--pattern` specified. --- Makefile | 13 ++++++++++--- benchmark/benchmark-pandoc.hs | 14 +++++++------- pandoc.cabal | 6 +++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 24df6da46..04b57939d 100644 --- a/Makefile +++ b/Makefile @@ -51,10 +51,17 @@ ghcid-test: ghcid -c "stack repl --ghc-options=-XNoImplicitPrelude --flag 'pandoc:embed_data_files' --ghci-options=-fobject-code pandoc:lib pandoc:test-pandoc" bench: - stack bench --benchmark-arguments='$(BENCHARGS) $(BASELINE) --csv bench_$(TIMESTAMP).csv' --ghc-options '-Rghc-timing $(GHCOPTS)' + stack bench \ + --ghc-options '-Rghc-timing $(GHCOPTS)' \ + --benchmark-arguments='--small --time-limit=2 \ + --match=pattern $(PATTERN)' 2>&1 | \ + tee "bench_latest.txt" + perl -pe 's/\x1b\[[0-9;]*[mGK]//g;s/\r//;' bench_latest.txt > \ + "bench_$(TIMESTAMP).txt" -weigh: - stack build --ghc-options '$(GHCOPTS)' pandoc:weigh-pandoc && stack exec weigh-pandoc + +# With tasty-bench, we used +# --benchmark-arguments='$(BENCHARGS) $(BASELINE) --csv bench_$(TIMESTAMP).csv' --ghc-options '-Rghc-timing $(GHCOPTS)' reformat: for f in $(SOURCEFILES); do echo $$f; stylish-haskell -i $$f ; done diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs index a4e72f584..f9a872011 100644 --- a/benchmark/benchmark-pandoc.hs +++ b/benchmark/benchmark-pandoc.hs @@ -18,12 +18,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -} import Text.Pandoc import Text.Pandoc.MIME -import Control.Monad (when) +import Control.DeepSeq (force) import Control.Monad.Except (throwError) import qualified Text.Pandoc.UTF8 as UTF8 import qualified Data.ByteString as B import qualified Data.Text as T -import Test.Tasty.Bench +import Gauge import qualified Data.ByteString.Lazy as BL import Data.Maybe (mapMaybe) import Data.List (sortOn) @@ -31,10 +31,10 @@ import Data.List (sortOn) readerBench :: Pandoc -> T.Text -> Maybe Benchmark +readerBench _ name + | name `elem` ["bibtex", "biblatex", "csljson"] = Nothing readerBench doc name = either (const Nothing) Just $ runPure $ do - when (name `elem` ["bibtex", "biblatex", "csljson"]) $ - throwError $ PandocSomeError $ name <> " not supported for benchmark" (rdr, rexts) <- getReader name (wtr, wexts) <- getWriter name case (rdr, wtr) of @@ -65,10 +65,10 @@ writerBench :: [(FilePath, MimeType, BL.ByteString)] -> Pandoc -> T.Text -> Maybe Benchmark +writerBench _ _ name + | name `elem` ["bibtex", "biblatex", "csljson"] = Nothing writerBench imgs doc name = either (const Nothing) Just $ runPure $ do - when (name `elem` ["bibtex", "biblatex", "csljson"]) $ - throwError $ PandocSomeError $ name <> " not supported for benchmark" (wtr, wexts) <- getWriter name case wtr of TextWriter writerFun -> @@ -90,7 +90,7 @@ main :: IO () main = do inp <- UTF8.toText <$> B.readFile "test/testsuite.txt" let opts = def - let doc = either (error . show) id $ runPure $ readMarkdown opts inp + let doc = either (error . show) force $ runPure $ readMarkdown opts inp defaultMain [ env getImages $ \imgs -> bgroup "writers" $ mapMaybe (writerBench imgs doc . fst) diff --git a/pandoc.cabal b/pandoc.cabal index ad3b64909..647505211 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -826,8 +826,8 @@ benchmark benchmark-pandoc hs-source-dirs: benchmark build-depends: bytestring, containers, - tasty, - tasty-bench >= 0.2 && <= 0.3, + gauge >= 0.2 && < 0.3, mtl >= 2.2 && < 2.3, text >= 1.1.1.0 && < 1.3, - time + time, + deepseq -- cgit v1.2.3