diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-11-18 14:03:08 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-11-18 14:03:33 +0100 |
commit | aabf10b8bdcfc1620aa2b0f7a57a3b562f5b8039 (patch) | |
tree | 0cdcdef468c0b4b68378fbdd4dd34fa6f3f13d3b /benchmark | |
parent | 31076adf090b8b87f5bab90c8b91f872f81aa2bd (diff) | |
download | pandoc-aabf10b8bdcfc1620aa2b0f7a57a3b562f5b8039.tar.gz |
Added weigh-pandoc for memory usage diagnostics.
See #3169.
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/weigh-pandoc.hs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/benchmark/weigh-pandoc.hs b/benchmark/weigh-pandoc.hs new file mode 100644 index 000000000..198d09b46 --- /dev/null +++ b/benchmark/weigh-pandoc.hs @@ -0,0 +1,37 @@ +import Weigh +import Text.Pandoc + +main :: IO () +main = do + doc <- read <$> readFile "tests/testsuite.native" + mainWith $ do + func "Pandoc document" id doc + mapM_ + (\(n,r) -> weighReader doc n (handleError . r def{ readerSmart = True })) + [("markdown", readMarkdown) + ,("html", readHtml) + ,("docbook", readDocBook) + ,("latex", readLaTeX) + ,("commonmark", readCommonMark) + ] + mapM_ + (\(n,w) -> weighWriter doc n (w def)) + [("markdown", writeMarkdown) + ,("html", writeHtmlString) + ,("docbook", writeDocbook) + ,("latex", writeLaTeX) + ,("commonmark", writeCommonMark) + ] + +weighWriter :: Pandoc -> String -> (Pandoc -> String) -> Weigh () +weighWriter doc name writer = func (name ++ " writer") writer doc + +weighReader :: Pandoc -> String -> (String -> Pandoc) -> Weigh () +weighReader doc name reader = do + case lookup name writers of + Just (PureStringWriter writer) -> + let inp = writer def{ writerWrapText = WrapAuto} doc + in func (name ++ " reader") reader inp + _ -> return () -- no writer for reader + + |