2import Text.Pandoc.Shared (readDataFile, normalize)
4import Data.List (isSuffixOf)
5import Text.JSON.Generic
8 -> (String, ParserState -> String -> Pandoc)
10readerBench doc (name, reader) =
11 let writer = case lookup name writers of
13 Nothing -> error $ "Could not find writer for " ++ name
14 inp = writer defaultWriterOptions{ writerWrapText = True
15 , writerLiterateHaskell =
16 "+lhs" `isSuffixOf` name } doc
17 -- we compute the length to force full evaluation
18 getLength (Pandoc (Meta a b c) d) =
19 length a + length b + length c + length d
20 in bench (name ++ " reader") $ whnf (getLength .
21 reader defaultParserState{ stateSmart = True
22 , stateStandalone = True
23 , stateLiterateHaskell =
24 "+lhs" `isSuffixOf` name }) inp
27 -> (String, WriterOptions -> Pandoc -> String)
29writerBench doc (name, writer) = bench (name ++ " writer") $ nf
30 (writer defaultWriterOptions{
32 , writerLiterateHaskell = "+lhs" `isSuffixOf` name }) doc
34normalizeBench :: Pandoc -> [Benchmark]
35normalizeBench doc = [ bench "normalize - with" $ nf (encodeJSON . normalize) doc
36 , bench "normalize - without" $ nf encodeJSON doc
40 inp <- readDataFile (Just ".") "README"
41 let ps = defaultParserState{ stateSmart = True }
42 let doc = readMarkdown ps inp
43 let readerBs = map (readerBench doc) readers
44 defaultMain $ map (writerBench doc) writers ++ readerBs ++ normalizeBench doc
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list