2import Text.Pandoc.Shared (normalize)
5import Text.JSON.Generic
6import System.Environment (getArgs)
10 -> (String, ReaderOptions -> String -> IO Pandoc)
12readerBench doc (name, reader) =
13 let writer = case lookup name writers of
14 Just (PureStringWriter w) -> w
15 _ -> error $ "Could not find writer for " ++ name
16 inp = writer def{ writerWrapText = True } 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") $ whnfIO $ getLength `fmap`
21 (reader def{ readerSmart = True }) inp
24 -> (String, WriterOptions -> Pandoc -> String)
26writerBench doc (name, writer) = bench (name ++ " writer") $ nf
27 (writer def{ writerWrapText = True }) doc
29normalizeBench :: Pandoc -> [Benchmark]
30normalizeBench doc = [ bench "normalize - with" $ nf (encodeJSON . normalize) doc
31 , bench "normalize - without" $ nf encodeJSON doc
37 (conf,_) <- parseArgs defaultConfig{ cfgSamples = Last $ Just 20 } defaultOptions args
38 inp <- readFile "README"
39 inp2 <- readFile "tests/testsuite.txt"
40 let opts = def{ readerSmart = True }
41 let doc = readMarkdown opts $ inp ++ unlines (drop 3 $ lines inp2)
42 let readerBs = map (readerBench doc) readers
43 let writers' = [(n,w) | (n, PureStringWriter w) <- writers]
44 defaultMainWith conf (return ()) $
45 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