git.iko.soy/typeable/pandoc
on master help sign in
Added weigh-pandoc for memory usage diagnostics.

See #3169.

commitaabf10b8bdcfc1620aa2b0f7a57a3b562f5b8039 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 18 Nov 2016, 14:03 (10 years ago) parent31076ad
2 files changed+57
benchmark/weigh-pandoc.hs+37 pandoc.cabal+20
benchmark/weigh-pandoc.hsnew file+37
@@ -0,0 +1,37 @@
1+import Weigh
2+import Text.Pandoc
3+
4+main :: IO ()
5+main = do
6+ doc <- read <$> readFile "tests/testsuite.native"
7+ mainWith $ do
8+ func "Pandoc document" id doc
9+ mapM_
10+ (\(n,r) -> weighReader doc n (handleError . r def{ readerSmart = True }))
11+ [("markdown", readMarkdown)
12+ ,("html", readHtml)
13+ ,("docbook", readDocBook)
14+ ,("latex", readLaTeX)
15+ ,("commonmark", readCommonMark)
16+ ]
17+ mapM_
18+ (\(n,w) -> weighWriter doc n (w def))
19+ [("markdown", writeMarkdown)
20+ ,("html", writeHtmlString)
21+ ,("docbook", writeDocbook)
22+ ,("latex", writeLaTeX)
23+ ,("commonmark", writeCommonMark)
24+ ]
25+
26+weighWriter :: Pandoc -> String -> (Pandoc -> String) -> Weigh ()
27+weighWriter doc name writer = func (name ++ " writer") writer doc
28+
29+weighReader :: Pandoc -> String -> (String -> Pandoc) -> Weigh ()
30+weighReader doc name reader = do
31+ case lookup name writers of
32+ Just (PureStringWriter writer) ->
33+ let inp = writer def{ writerWrapText = WrapAuto} doc
34+ in func (name ++ " reader") reader inp
35+ _ -> return () -- no writer for reader
36+
37+
pandoc.cabal+20
@@ -236,6 +236,10 @@ Flag trypandoc
236236 Description: Build trypandoc cgi executable.
237237 Default: False
238238
239+Flag weigh-pandoc
240+ Description: Build weigh-pandoc to measure memory usage.
241+ Default: False
242+
239243Flag https
240244 Description: Enable support for downloading of resources over https.
241245 Default: True
@@ -472,6 +476,22 @@ Executable trypandoc
472476 else
473477 Buildable: False
474478
479+Executable weigh-pandoc
480+ Main-Is: weigh-pandoc.hs
481+ Hs-Source-Dirs: benchmark
482+ if impl(ghc < 7.10)
483+ Hs-Source-Dirs: prelude
484+ Other-Modules: Prelude
485+ if flag(weigh-pandoc)
486+ Build-Depends: pandoc,
487+ base >= 4.2 && < 5,
488+ weigh >= 0.0 && < 0.1
489+ Buildable: True
490+ else
491+ Buildable: False
492+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
493+ Default-Language: Haskell98
494+
475495Test-Suite test-pandoc
476496 Type: exitcode-stdio-1.0
477497 Main-Is: test-pandoc.hs