on master help sign in
Fix a bug that caused reopening of the wrong file
commit773f5a7c70162672e6700f9caf5dbef1a1d4decd authorHarendra Kumar <harendra.kumar@gmail.com> dateTue 18 Jun 2019, 16:19 (7 years ago) parent2bb75a0
1 file changed+12−11
benchmark/FileIO.hs+12−11
benchmark/FileIO.hs+12−11
@@ -31,9 +31,6 @@ data Handles = Handles Handle Handle
3131scratchDir :: String
3232scratchDir = "benchmark/scratch/"
3333
34−infile :: String
35−infile = scratchDir ++ "in-100MB.txt"
36−
3734outfile :: String
3835outfile = scratchDir ++ "out.txt"
3936
@@ -42,6 +39,13 @@ blockSize = 32768
4239blockCount = 3200
4340
4441#ifdef DEVBUILD
42+-- This is a 500MB text file for text processing benchmarks. We cannot
43+-- have it in the repo, therefore we use it locally with DEVBUILD
44+-- conditional (enabled by "dev" cabal flag). Some tests that depend on
45+-- this file are available only in DEVBUILD mode.
46+infile :: String
47+infile = "benchmark/text-processing/gutenberg-500.txt"
48+
4549fileSize :: Int
4650fileSize = blockSize * blockCount
4751
@@ -62,17 +66,14 @@ isSpace c
6266 | otherwise = iswspace (ord c) /= 0
6367 where
6468 uc = fromIntegral (ord c) :: Word
69+#else
70+infile :: String
71+infile = scratchDir ++ "in-100MB.txt"
6572#endif
6673
6774main :: IO ()
6875main = do
69−#ifdef DEVBUILD
70− -- This is a 500MB text file for text processing benchmarks. We cannot
71− -- have it in the repo, therefore we use it locally with DEVBUILD
72− -- conditional (enabled by "dev" cabal flag). Some tests that depend on
73− -- this file are available only in DEVBUILD mode.
74− inHandle <- openFile "benchmark/text-processing/gutenberg-500.txt" ReadMode
75−#else
76+#ifndef DEVBUILD
7677 -- XXX will this work on windows/msys?
7778 let cmd = "mkdir -p " ++ scratchDir
7879 ++ "; test -e " ++ infile
@@ -83,8 +84,8 @@ main = do
8384 ++ ";}"
8485
8586 runProcess_ (shell cmd)
86− inHandle <- openFile infile ReadMode
8787#endif
88+ inHandle <- openFile infile ReadMode
8889 outHandle <- openFile outfile WriteMode
8990 href <- newIORef $ Handles inHandle outHandle
9091 devNull <- openFile "/dev/null" WriteMode