Skip to content

Commit

Permalink
Update benchmarks for ghc 8.6.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Oct 14, 2018
1 parent 275594f commit 2018f41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
29 changes: 17 additions & 12 deletions benchmark/benchmark-pandoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
import Prelude
import Text.Pandoc
import Text.Pandoc.Error (PandocError(..))
import Control.Monad.Except (throwError)
import qualified Text.Pandoc.UTF8 as UTF8
import qualified Data.ByteString as B
import Criterion.Main
Expand All @@ -37,14 +39,15 @@ readerBench doc name =
$ nf (\i -> either (error . show) id $ runPure (readerFun i))
inp
Left _ -> Nothing
where res = runPure $ do
(TextReader r, rexts)
<- either (fail . show) return $ getReader name
(TextWriter w, wexts)
<- either (fail . show) return $ getWriter name
inp <- w def{ writerWrapText = WrapAuto, writerExtensions = wexts }
doc
return (r def{ readerExtensions = rexts }, inp)
where res = runPure $
case (getReader name, getWriter name) of
(Right (TextReader r, rexts),
Right (TextWriter w, wexts)) -> do
inp <- w def{ writerWrapText = WrapAuto
, writerExtensions = wexts } doc
return $ (r def{ readerExtensions = rexts }, inp)
_ -> throwError $ PandocSomeError
$ "could not get text reader and writer for " ++ name

writerBench :: Pandoc
-> String
Expand All @@ -55,11 +58,13 @@ writerBench doc name =
Just $ bench (name ++ " writer")
$ nf (\d -> either (error . show) id $
runPure (writerFun d)) doc
_ -> Nothing
Left _ -> Nothing
where res = runPure $ do
(TextWriter w, wexts)
<- either (fail . show) return $ getWriter name
return $ w def{ writerExtensions = wexts }
case (getWriter name) of
Right (TextWriter w, wexts) ->
return $ w def{ writerExtensions = wexts }
_ -> throwError $ PandocSomeError
$ "could not get text reader and writer for " ++ name

main :: IO ()
main = do
Expand Down
1 change: 1 addition & 0 deletions pandoc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ benchmark benchmark-pandoc
time, bytestring, containers,
base >= 4.8 && < 5,
text >= 0.11 && < 1.3,
mtl >= 2.2 && < 2.3,
criterion >= 1.0 && < 1.6
if impl(ghc < 8.0)
build-depends: semigroups == 0.18.*
Expand Down

0 comments on commit 2018f41

Please sign in to comment.