summaryrefslogtreecommitdiff
path: root/benchmark/benchmark-pandoc.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-12-10 23:42:28 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-25 17:07:41 +0100
commit35699ee5339e6a0b865d01246f6553f45551cc78 (patch)
treec1a3f44efa464603ba1dff496c605a483d42edf3 /benchmark/benchmark-pandoc.hs
parentb5d15670223ada11a357161f3b057fae6f852554 (diff)
Fixed up weigh-pandoc and benchmark-pandoc so they build.
Diffstat (limited to 'benchmark/benchmark-pandoc.hs')
-rw-r--r--benchmark/benchmark-pandoc.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs
index e2707de20..ce2e054e7 100644
--- a/benchmark/benchmark-pandoc.hs
+++ b/benchmark/benchmark-pandoc.hs
@@ -22,14 +22,15 @@ import Data.Maybe (mapMaybe)
import Debug.Trace (trace)
readerBench :: Pandoc
- -> (String, ReaderOptions -> String -> IO (Either PandocError Pandoc))
+ -> (String, ReaderOptions -> String -> Pandoc)
-> Maybe Benchmark
readerBench doc (name, reader) =
case lookup name writers of
- Just (PureStringWriter writer) ->
- let inp = writer def{ writerWrapText = WrapAuto} doc
- in return $ bench (name ++ " reader") $ nfIO $
- (fmap handleError <$> reader def{ readerSmart = True }) inp
+ Just (StringWriter writer) ->
+ let inp = either (error . show) id $ runPure
+ $ writer def{ writerWrapText = WrapAuto} doc
+ in return $ bench (name ++ " reader") $ nf
+ (reader def{ readerSmart = True }) inp
_ -> trace ("\nCould not find writer for " ++ name ++ "\n") Nothing
writerBench :: Pandoc
@@ -42,11 +43,13 @@ main :: IO ()
main = do
inp <- readFile "tests/testsuite.txt"
let opts = def{ readerSmart = True }
- let doc = handleError $ readMarkdown opts inp
- let readers' = [(n,r) | (n, StringReader r) <- readers]
+ let doc = either (error . show) id $ runPure $ readMarkdown opts inp
+ let readers' = [(n, \o -> either (error . show) id . runPure . r o)
+ | (n, StringReader r) <- readers]
let readerBs = mapMaybe (readerBench doc)
$ filter (\(n,_) -> n /="haddock") readers'
- let writers' = [(n,w) | (n, PureStringWriter w) <- writers]
+ let writers' = [(n, \o -> either (error . show) id . runPure . w o)
+ | (n, StringWriter w) <- writers]
let writerBs = map (writerBench doc)
$ writers'
defaultMainWith defaultConfig{ timeLimit = 6.0 }