aboutsummaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-13 23:10:27 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-13 23:13:53 -0700
commit2018f41193ab622cc111bb451f2dca783fde89ba (patch)
treecba54dc96d7392113f20c305891ae1f6aca4d0c7 /benchmark
parent275594f7f77e9ebb6422d35bc4e6d4f439f6de8e (diff)
downloadpandoc-2018f41193ab622cc111bb451f2dca783fde89ba.tar.gz
Update benchmarks for ghc 8.6.1.
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/benchmark-pandoc.hs29
1 files changed, 17 insertions, 12 deletions
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs
index db6c2eb9c..3ed7011e4 100644
--- a/benchmark/benchmark-pandoc.hs
+++ b/benchmark/benchmark-pandoc.hs
@@ -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
@@ -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
@@ -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