1{-# LANGUAGE TupleSections #-}
3Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation; either version 2 of the License, or
8(at your option) any later version.
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20import qualified Text.Pandoc.UTF8 as UTF8
21import qualified Data.ByteString as B
23import Criterion.Types (Config(..))
24import Data.List (intersect)
25import Data.Maybe (mapMaybe)
26import System.Environment (getArgs)
33 Right (readerFun, inp) ->
34 Just $ bench (name ++ " reader")
35 $ nf (\i -> either (error . show) id $ runPure (readerFun i))
38 where res = runPure $ do
40 <- either (fail . show) return $ getReader name
42 <- either (fail . show) return $ getWriter name
43 inp <- w def{ writerWrapText = WrapAuto, writerExtensions = wexts }
45 return (r def{ readerExtensions = rexts }, inp)
53 Just $ bench (name ++ " writer")
54 $ nf (\d -> either (error . show) id $
55 runPure (writerFun d)) doc
57 where res = runPure $ do
59 <- either (fail . show) return $ getWriter name
60 return $ w def{ writerExtensions = wexts }
64 args <- filter (\x -> take 1 x /= "-") <$> getArgs
66 let matchReader (n, TextReader _) =
67 null args || ("reader" `elem` args && n `elem` args)
69 let matchWriter (n, TextWriter _) =
70 null args || ("writer" `elem` args && n `elem` args)
72 let matchedReaders = map fst $ (filter matchReader readers
73 :: [(String, Reader PandocPure)])
74 let matchedWriters = map fst $ (filter matchWriter writers
75 :: [(String, Writer PandocPure)])
76 inp <- UTF8.toText <$> B.readFile "test/testsuite.txt"
78 let doc = either (error . show) id $ runPure $ readMarkdown opts inp
79 let readerBs = mapMaybe (readerBench doc)
80 $ filter (/="haddock")
81 (matchedReaders `intersect` matchedWriters)
82 -- we need the corresponding writer to generate
83 -- input for the reader
84 let writerBs = mapMaybe (writerBench doc) matchedWriters
85 defaultMainWith defaultConfig{ timeLimit = 6.0 }
86 (writerBs ++ readerBs)
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