diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-06-10 20:57:38 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-06-10 20:57:38 +0200 |
commit | f43504f9f4cad4368ea9e8834d97f3ad87ac1494 (patch) | |
tree | ea727d7853c932144468e54468b71b7f210129e0 | |
parent | 94b3dacb4ea7e5e99ab62286b13877b92f9391b3 (diff) | |
download | pandoc-f43504f9f4cad4368ea9e8834d97f3ad87ac1494.tar.gz |
Fixed benchmark to work with Text readers.
-rw-r--r-- | benchmark/benchmark-pandoc.hs | 12 | ||||
-rw-r--r-- | pandoc.cabal | 1 |
2 files changed, 8 insertions, 5 deletions
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs index 7294c74a4..be44c462f 100644 --- a/benchmark/benchmark-pandoc.hs +++ b/benchmark/benchmark-pandoc.hs @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -} import Text.Pandoc import Text.Pandoc.Class hiding (getCurrentTime) +import qualified Text.Pandoc.UTF8 as UTF8 +import Data.Text (Text, pack) import Data.Time (getCurrentTime) import qualified Data.ByteString as B import qualified Data.Map as Map @@ -27,12 +29,12 @@ import Debug.Trace (trace) import System.Environment (getArgs) readerBench :: Pandoc - -> (String, ReaderOptions -> String -> Pandoc) + -> (String, ReaderOptions -> Text -> Pandoc) -> Maybe Benchmark readerBench doc (name, reader) = case lookup name writers of Just (StringWriter writer) -> - let inp = either (error . show) id $ runPure + let inp = either (error . show) pack $ runPure $ writer def{ writerWrapText = WrapAuto} doc in return $ bench (name ++ " reader") $ nf (reader def) inp @@ -47,7 +49,7 @@ writerBench doc (name, writer) = bench (name ++ " writer") $ nf main :: IO () main = do args <- getArgs - let matchReader (n, StringReader _) = + let matchReader (n, TextReader _) = case args of [] -> True [x] -> x == n @@ -61,7 +63,7 @@ main = do matchWriter (_, _) = False let matchedReaders = filter matchReader readers let matchedWriters = filter matchWriter writers - inp <- readFile "test/testsuite.txt" + inp <- UTF8.toText <$> B.readFile "test/testsuite.txt" lalune <- B.readFile "test/lalune.jpg" movie <- B.readFile "test/movie.jpg" time <- getCurrentTime @@ -74,7 +76,7 @@ main = do let doc = either (error . show) id $ runPure $ readMarkdown opts inp let readers' = [(n, \o d -> either (error . show) id $ runPure $ r o d) - | (n, StringReader r) <- matchedReaders] + | (n, TextReader r) <- matchedReaders] let readerBs = mapMaybe (readerBench doc) $ filter (\(n,_) -> n /="haddock") readers' let writers' = [(n, \o d -> diff --git a/pandoc.cabal b/pandoc.cabal index 64c7b88c9..5ba020326 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -584,6 +584,7 @@ benchmark benchmark-pandoc Build-Depends: pandoc, time, bytestring, containers, base >= 4.2 && < 5, + text >= 0.11 && < 1.3, syb >= 0.1 && < 0.8, criterion >= 1.0 && < 1.3 Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind |