diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-01-27 11:15:45 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-27 11:15:55 +0100 |
commit | 8a61d943f590f8ba1df8dbc5840301e26c9b4db9 (patch) | |
tree | e299fdfc31eb5e16df9c17e02d3c4a2467e5fd57 /benchmark | |
parent | 4ccbdf4e8dabee046106bda8826f7211d8d23546 (diff) | |
download | pandoc-8a61d943f590f8ba1df8dbc5840301e26c9b4db9.tar.gz |
Fix up benchmarks so they compile.
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/benchmark-pandoc.hs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs index ce2e054e7..d5e3405be 100644 --- a/benchmark/benchmark-pandoc.hs +++ b/benchmark/benchmark-pandoc.hs @@ -16,6 +16,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -} import Text.Pandoc +import Text.Pandoc.Class hiding (getCurrentTime) +import Data.Time (getCurrentTime) +import qualified Data.ByteString as B +import qualified Data.Map as Map import Criterion.Main import Criterion.Types (Config(..)) import Data.Maybe (mapMaybe) @@ -30,7 +34,7 @@ readerBench doc (name, reader) = let inp = either (error . show) id $ runPure $ writer def{ writerWrapText = WrapAuto} doc in return $ bench (name ++ " reader") $ nf - (reader def{ readerSmart = True }) inp + (reader def) inp _ -> trace ("\nCould not find writer for " ++ name ++ "\n") Nothing writerBench :: Pandoc @@ -42,13 +46,23 @@ writerBench doc (name, writer) = bench (name ++ " writer") $ nf main :: IO () main = do inp <- readFile "tests/testsuite.txt" - let opts = def{ readerSmart = True } + lalune <- B.readFile "tests/lalune.jpg" + movie <- B.readFile "tests/movie.jpg" + time <- getCurrentTime + let setupFakeFiles = modifyPureState $ \st -> st{ stFiles = + FileTree $ Map.fromList [ + ("lalune.jpg", FileInfo time lalune), + ("movie.jpg", FileInfo time movie) + ]} + let opts = def let doc = either (error . show) id $ runPure $ readMarkdown opts inp - let readers' = [(n, \o -> either (error . show) id . runPure . r o) + let readers' = [(n, \o d -> + either (error . show) id $ runPure $ r o d) | (n, StringReader r) <- readers] let readerBs = mapMaybe (readerBench doc) $ filter (\(n,_) -> n /="haddock") readers' - let writers' = [(n, \o -> either (error . show) id . runPure . w o) + let writers' = [(n, \o d -> + either (error . show) id $ runPure $ setupFakeFiles >> w o d) | (n, StringWriter w) <- writers] let writerBs = map (writerBench doc) $ writers' |