@@ -40,6 +40,7 @@ module Main (main) where
4040
4141-- base.
4242import Control.Applicative (some , (<|>) )
43+ import System.IO (hPutStrLn , stderr )
4344-- package: time.
4445import Data.Time.Clock (getCurrentTime , diffUTCTime )
4546-- package: async.
@@ -145,28 +146,30 @@ optsParser = CliOpts <$>
145146run :: CliOpts -> IO ()
146147run (CliOpts _ _ [] ) = putStrLn " Nothing to do, bye!"
147148run cliOpts@ (CliOpts _ parallel (b@ (FilterReduce. MkFilterReduce f r): _)) = do
148- t0 <- getCurrentTime
149- print b
149+ -- Will print to stderr the time elapsed.
150+ t0 <- getCurrentTime
151+ -- Print filter used to stderr and as a top line comment.
152+ hPutStrLn stderr (show b)
153+ putStrLn $ " # " ++ show b
150154 if not parallel
151155 then do
152- ------------------------------------
153- putStrLn " -------------------------"
154- putStrLn " Apply filter to all files"
155- putStrLn " -------------------------"
156- ------------------------------------
156+ -------------------------------------------------------
157+ hPutStrLn stderr " ----------- -------------------------"
158+ hPutStrLn stderr " Apply filter to all files one by one "
159+ hPutStrLn stderr " ----------- -------------------------"
160+ -------------------------------------------------------
157161 mapM_
158162 (\ (logName,fp) -> do
159163 ans <- FilterReduce. filterReduce f r fp
160- print logName
161- Reducer. printAns r ans
164+ fileOutput logName r ans
162165 )
163166 (files cliOpts)
164167 else do
165- ---------------------------------------------------------
166- putStrLn " ----------------------------------------------"
167- putStrLn " Do the same with all files but now in parallel"
168- putStrLn " ----------------------------------------------"
169- ---------------------------------------------------------
168+ -----------------------------------------------------------------
169+ hPutStrLn stderr " ----------------------------------------------"
170+ hPutStrLn stderr " Do the same with all files but now in parallel"
171+ hPutStrLn stderr " ----------------------------------------------"
172+ -----------------------------------------------------------------
170173 ansParallel <- Async. mapConcurrently
171174 (\ (logName,fp) -> do
172175 ans <- FilterReduce. filterReduce f r fp
@@ -175,16 +178,22 @@ run cliOpts@(CliOpts _ parallel (b@(FilterReduce.MkFilterReduce f r):_)) = do
175178 (files cliOpts)
176179 mapM_
177180 (\ (logName,ans) -> do
178- putStrLn $ " # " ++ logName
179- Reducer. printAns r ans
180- putStrLn " "
181+ fileOutput logName r ans
181182 )
182183 ansParallel
183184 t1 <- getCurrentTime
184- print $ diffUTCTime t1 t0
185+ hPutStrLn stderr $ show $ diffUTCTime t1 t0
185186 -- End
186187 return ()
187188
189+ fileOutput :: Reducer. Reducer r => String -> r -> Reducer. Accum r -> IO ()
190+ fileOutput logName r acc = do
191+ putStrLn $ " # " ++ logName
192+ Reducer. printAns r acc
193+ -- Two empty lines so gnuplot undertands it as a different data block.
194+ putStrLn " "
195+ putStrLn " "
196+
188197--------------------------------------------------------------------------------
189198
190199-- TODO:
0 commit comments