on master help sign in
Fix a bug that caused reopening of the wrong file
773f5a7Harendra Kumar
benchmark/FileIO.hs+12−11
@@ -31,9 +31,6 @@ data Handles = Handles Handle Handle
31scratchDir :: String
31scratchDir :: String
32scratchDir = "benchmark/scratch/"
32scratchDir = "benchmark/scratch/"
33
33
34−infile :: String
35−infile = scratchDir ++ "in-100MB.txt"
36−
37outfile :: String
34outfile :: String
38outfile = scratchDir ++ "out.txt"
35outfile = scratchDir ++ "out.txt"
39
36
@@ -42,6 +39,13 @@ blockSize = 32768
42blockCount = 3200
39blockCount = 3200
43
40
44#ifdef DEVBUILD
41#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+
45fileSize :: Int
49fileSize :: Int
46fileSize = blockSize * blockCount
50fileSize = blockSize * blockCount
47
51
@@ -62,17 +66,14 @@ isSpace c
62 | otherwise = iswspace (ord c) /= 0
66 | otherwise = iswspace (ord c) /= 0
63 where
67 where
64 uc = fromIntegral (ord c) :: Word
68 uc = fromIntegral (ord c) :: Word
69+#else
70+infile :: String
71+infile = scratchDir ++ "in-100MB.txt"
65#endif
72#endif
66
73
67main :: IO ()
74main :: IO ()
68main = do
75main = do
69−#ifdef DEVBUILD
76+#ifndef 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 -- XXX will this work on windows/msys?
77 -- XXX will this work on windows/msys?
77 let cmd = "mkdir -p " ++ scratchDir
78 let cmd = "mkdir -p " ++ scratchDir
78 ++ "; test -e " ++ infile
79 ++ "; test -e " ++ infile
@@ -83,8 +84,8 @@ main = do
83 ++ ";}"
84 ++ ";}"
84
85
85 runProcess_ (shell cmd)
86 runProcess_ (shell cmd)
86− inHandle <- openFile infile ReadMode
87#endif
87#endif
88+ inHandle <- openFile infile ReadMode
88 outHandle <- openFile outfile WriteMode
89 outHandle <- openFile outfile WriteMode
89 href <- newIORef $ Handles inHandle outHandle
90 href <- newIORef $ Handles inHandle outHandle
90 devNull <- openFile "/dev/null" WriteMode
91 devNull <- openFile "/dev/null" WriteMode