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:
parent
d94f9b930a
commit
ff0fcedcb3
3 changed files with 20 additions and 13 deletions
13
Makefile
13
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"
|
ghcid -c "stack repl --ghc-options=-XNoImplicitPrelude --flag 'pandoc:embed_data_files' --ghci-options=-fobject-code pandoc:lib pandoc:test-pandoc"
|
||||||
|
|
||||||
bench:
|
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:
|
reformat:
|
||||||
for f in $(SOURCEFILES); do echo $$f; stylish-haskell -i $$f ; done
|
for f in $(SOURCEFILES); do echo $$f; stylish-haskell -i $$f ; done
|
||||||
|
|
|
@ -18,12 +18,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
-}
|
-}
|
||||||
import Text.Pandoc
|
import Text.Pandoc
|
||||||
import Text.Pandoc.MIME
|
import Text.Pandoc.MIME
|
||||||
import Control.Monad (when)
|
import Control.DeepSeq (force)
|
||||||
import Control.Monad.Except (throwError)
|
import Control.Monad.Except (throwError)
|
||||||
import qualified Text.Pandoc.UTF8 as UTF8
|
import qualified Text.Pandoc.UTF8 as UTF8
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Test.Tasty.Bench
|
import Gauge
|
||||||
import qualified Data.ByteString.Lazy as BL
|
import qualified Data.ByteString.Lazy as BL
|
||||||
import Data.Maybe (mapMaybe)
|
import Data.Maybe (mapMaybe)
|
||||||
import Data.List (sortOn)
|
import Data.List (sortOn)
|
||||||
|
@ -31,10 +31,10 @@ import Data.List (sortOn)
|
||||||
readerBench :: Pandoc
|
readerBench :: Pandoc
|
||||||
-> T.Text
|
-> T.Text
|
||||||
-> Maybe Benchmark
|
-> Maybe Benchmark
|
||||||
|
readerBench _ name
|
||||||
|
| name `elem` ["bibtex", "biblatex", "csljson"] = Nothing
|
||||||
readerBench doc name = either (const Nothing) Just $
|
readerBench doc name = either (const Nothing) Just $
|
||||||
runPure $ do
|
runPure $ do
|
||||||
when (name `elem` ["bibtex", "biblatex", "csljson"]) $
|
|
||||||
throwError $ PandocSomeError $ name <> " not supported for benchmark"
|
|
||||||
(rdr, rexts) <- getReader name
|
(rdr, rexts) <- getReader name
|
||||||
(wtr, wexts) <- getWriter name
|
(wtr, wexts) <- getWriter name
|
||||||
case (rdr, wtr) of
|
case (rdr, wtr) of
|
||||||
|
@ -65,10 +65,10 @@ writerBench :: [(FilePath, MimeType, BL.ByteString)]
|
||||||
-> Pandoc
|
-> Pandoc
|
||||||
-> T.Text
|
-> T.Text
|
||||||
-> Maybe Benchmark
|
-> Maybe Benchmark
|
||||||
|
writerBench _ _ name
|
||||||
|
| name `elem` ["bibtex", "biblatex", "csljson"] = Nothing
|
||||||
writerBench imgs doc name = either (const Nothing) Just $
|
writerBench imgs doc name = either (const Nothing) Just $
|
||||||
runPure $ do
|
runPure $ do
|
||||||
when (name `elem` ["bibtex", "biblatex", "csljson"]) $
|
|
||||||
throwError $ PandocSomeError $ name <> " not supported for benchmark"
|
|
||||||
(wtr, wexts) <- getWriter name
|
(wtr, wexts) <- getWriter name
|
||||||
case wtr of
|
case wtr of
|
||||||
TextWriter writerFun ->
|
TextWriter writerFun ->
|
||||||
|
@ -90,7 +90,7 @@ main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
inp <- UTF8.toText <$> B.readFile "test/testsuite.txt"
|
inp <- UTF8.toText <$> B.readFile "test/testsuite.txt"
|
||||||
let opts = def
|
let opts = def
|
||||||
let doc = either (error . show) id $ runPure $ readMarkdown opts inp
|
let doc = either (error . show) force $ runPure $ readMarkdown opts inp
|
||||||
defaultMain
|
defaultMain
|
||||||
[ env getImages $ \imgs ->
|
[ env getImages $ \imgs ->
|
||||||
bgroup "writers" $ mapMaybe (writerBench imgs doc . fst)
|
bgroup "writers" $ mapMaybe (writerBench imgs doc . fst)
|
||||||
|
|
|
@ -826,8 +826,8 @@ benchmark benchmark-pandoc
|
||||||
hs-source-dirs: benchmark
|
hs-source-dirs: benchmark
|
||||||
build-depends: bytestring,
|
build-depends: bytestring,
|
||||||
containers,
|
containers,
|
||||||
tasty,
|
gauge >= 0.2 && < 0.3,
|
||||||
tasty-bench >= 0.2 && <= 0.3,
|
|
||||||
mtl >= 2.2 && < 2.3,
|
mtl >= 2.2 && < 2.3,
|
||||||
text >= 1.1.1.0 && < 1.3,
|
text >= 1.1.1.0 && < 1.3,
|
||||||
time
|
time,
|
||||||
|
deepseq
|
||||||
|
|
Loading…
Reference in a new issue