git.iko.soy/typeable/pandoc
on master help sign in
Benchmark: default to sample size of 20 for speed.
commitfc738c631551b388824448522aef818cc5b65bb9 authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 27 Jul 2012, 11:13 (14 years ago) parent5b6e70c
1 file changed+6−1
benchmark/benchmark-pandoc.hs+6−1
benchmark/benchmark-pandoc.hs+6−1
@@ -1,8 +1,11 @@
11import Text.Pandoc
22import Text.Pandoc.Shared (readDataFile, normalize)
33import Criterion.Main
4+import Criterion.Config
45import Data.List (isSuffixOf)
56import Text.JSON.Generic
7+import System.Environment (getArgs)
8+import Data.Monoid
69
710readerBench :: Pandoc
811 -> (String, ReaderOptions -> String -> Pandoc)
@@ -37,12 +40,14 @@ normalizeBench doc = [ bench "normalize - with" $ nf (encodeJSON . normalize) do
3740
3841main :: IO ()
3942main = do
43+ args <- getArgs
44+ (conf,_) <- parseArgs defaultConfig{ cfgSamples = Last $ Just 20 } defaultOptions args
4045 inp <- readDataFile (Just ".") "README"
4146 inp2 <- readDataFile (Just ".") "tests/testsuite.txt"
4247 let opts = def{ readerSmart = True }
4348 let doc = readMarkdown opts $ inp ++ unlines (drop 3 $ lines inp2)
4449 let readerBs = map (readerBench doc) readers
4550 let writers' = [(n,w) | (n, PureStringWriter w) <- writers]
46− defaultMain $
51+ defaultMainWith conf (return ()) $
4752 map (writerBench doc) writers' ++ readerBs ++ normalizeBench doc
4853