Switch to gauge for now for benchmarks.

tasty-bench is displaying odd behavior, with different
timings depending on the `--pattern` specified.
This commit is contained in:
John MacFarlane 2021-03-15 22:50:18 -07:00
parent d94f9b930a
commit ff0fcedcb3
3 changed files with 20 additions and 13 deletions

View file

@ -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

View file

@ -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)

View file

@ -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