Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More accurate benchmark for normalize.

  • Loading branch information...
commit df0eecfc0e655c5cd78dbbd94273d0b7f9af9451 1 parent e4dedad
@jgm authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 Benchmark.hs
View
9 Benchmark.hs
@@ -2,6 +2,7 @@ import Text.Pandoc
import Text.Pandoc.Shared (readDataFile, normalize)
import Criterion.Main
import Data.List (isSuffixOf)
+import Text.JSON.Generic
readerBench :: Pandoc
-> (String, ParserState -> String -> Pandoc)
@@ -30,13 +31,15 @@ writerBench doc (name, writer) = bench (name ++ " writer") $ nf
writerWrapText = True
, writerLiterateHaskell = "+lhs" `isSuffixOf` name }) doc
-normalizeBench :: Pandoc -> Benchmark
-normalizeBench doc = bench "normalize" $ whnf normalize doc
+normalizeBench :: Pandoc -> [Benchmark]
+normalizeBench doc = [ bench "normalize - with" $ nf (encodeJSON . normalize) doc
+ , bench "normalize - without" $ nf encodeJSON doc
+ ]
main = do
inp <- readDataFile (Just ".") "README"
let ps = defaultParserState{ stateSmart = True }
let doc = readMarkdown ps inp
let readerBs = map (readerBench doc) readers
- defaultMain $ map (writerBench doc) writers ++ readerBs ++ [normalizeBench doc]
+ defaultMain $ map (writerBench doc) writers ++ readerBs ++ normalizeBench doc
Please sign in to comment.
Something went wrong with that request. Please try again.