summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-03-16 22:20:42 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2015-03-17 16:15:57 -0700
commite0d234e54d18a82a7c90aa3946f890140e200051 (patch)
tree014a55e724fb1835e30796d8f2dcd46cd1b75607 /benchmark
parent5721a5d34bc3c0ab4d7fb9424d9f0b6f7055da30 (diff)
Added CommonMark reader using cmark (libcmark bindings).
- Added commonmark as an input format. - Added `Text.Pandoc.Readers.CommonMark.readCommonMark`. - For now, we use the markdown writer to generate benchmark text for the CommonMark reader. We can change this when we get a writer.
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/benchmark-pandoc.hs18
1 files changed, 12 insertions, 6 deletions
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs
index bf67eaa4d..2a34696b9 100644
--- a/benchmark/benchmark-pandoc.hs
+++ b/benchmark/benchmark-pandoc.hs
@@ -26,12 +26,18 @@ import Debug.Trace (trace)
readerBench :: Pandoc
-> (String, ReaderOptions -> String -> IO Pandoc)
-> Maybe Benchmark
-readerBench doc (name, reader) = case lookup name writers of
- Just (PureStringWriter writer) ->
- let inp = writer def{ writerWrapText = True} doc
- in return $ bench (name ++ " reader") $ nfIO $
- (reader def{ readerSmart = True }) inp
- _ -> trace ("\nCould not find writer for " ++ name ++ "\n") Nothing
+readerBench doc (name, reader) =
+ case lookup name writers of
+ Just (PureStringWriter writer) ->
+ let inp = writer def{ writerWrapText = True} doc
+ in return $ bench (name ++ " reader") $ nfIO $
+ (reader def{ readerSmart = True }) inp
+ _ | name == "commonmark" ->
+ let inp = writeMarkdown def{ writerWrapText = True} doc
+ in return $ bench (name ++ " reader") $ nfIO $
+ (reader def{ readerSmart = True }) inp
+ | otherwise -> trace ("\nCould not find writer for " ++ name ++
+ "\n") Nothing
writerBench :: Pandoc
-> (String, WriterOptions -> Pandoc -> String)