--
-----------------------------------------------------------------------------
-module Slurp (Status(..), Results(..), ResultTable(..), parse_log) where
+module Slurp (Status(..), Results(..), ResultTable, parse_log) where
import CmdLine
-import Data.FiniteMap
+
+import qualified Data.Map as Map
+import Data.Map (Map)
import Text.Regex
import Data.Maybe
-- import Debug.Trace
-----------------------------------------------------------------------------
-- This is the structure into which we collect our results:
-type ResultTable = FiniteMap String Results
+type ResultTable = Map String Results
data Status
= NotDone
| WrongStderr
data Results = Results {
- compile_time :: FiniteMap String Float,
- module_size :: FiniteMap String Int,
+ compile_time :: Map String Float,
+ module_size :: Map String Int,
binary_size :: Maybe Int,
link_time :: Maybe Float,
run_time :: [Float],
}
emptyResults = Results {
- compile_time = emptyFM,
- module_size = emptyFM,
+ compile_time = Map.empty,
+ module_size = Map.empty,
binary_size = Nothing,
link_time = Nothing,
run_time = [],
==nofib== boyer2: time to compile Checker follows...
-}
-banner_re = mkRegex "^==nofib==[ \t]+([A-Za-z0-9\\-_]+):[ \t]+(size of|time to link|time to run|time to compile)[ \t]+([A-Za-z0-9\\-_]+)(\\.o)?[ \t]+follows"
+-- NB. the hyphen must come last (or first) inside [...] to stand for itself.
+banner_re = mkRegex "^==nofib==[ \t]+([A-Za-z0-9_-]+):[ \t]+(size of|time to link|time to run|time to compile)[ \t]+([A-Za-z0-9_-]+)(\\.o)?[ \t]+follows"
{-
This regexp for the output of "time" works on FreeBSD, other versions
. chunk_log [] [] -- break at banner lines
. lines
-combine_results :: [(String,Results)] -> FiniteMap String Results
-combine_results = foldr f emptyFM
+combine_results :: [(String,Results)] -> Map String Results
+combine_results = foldr f Map.empty
where
- f (prog,results) fm = addToFM_C combine2Results fm prog results
+ f (prog,results) fm = Map.insertWith (flip combine2Results) prog results fm
combine2Results
gc_time = gt2, gc_work = gw2,
binary_size = bs2, allocs = al2,
run_status = rs2, compile_status = cs2 }
- = Results{ compile_time = plusFM_C const ct1 ct2,
- module_size = plusFM_C const ms1 ms2,
+ = Results{ compile_time = Map.unionWith (flip const) ct1 ct2,
+ module_size = Map.unionWith (flip const) ms1 ms2,
link_time = combMaybes lt1 lt2,
run_time = rt1 ++ rt2,
mut_time = mt1 ++ mt2,
parse_compile_time prog mod (l:ls) =
case matchRegex time_re l of {
Just (real:user:system:_) ->
- let ct = addToFM emptyFM mod (read user)
+ let ct = Map.singleton mod (read user)
in
[(prog,emptyResults{compile_time = ct})];
Nothing ->
case matchRegex time_gnu17_re l of {
Just (user:system:elapsed:_) ->
- let ct = addToFM emptyFM mod (read user)
+ let ct = Map.singleton mod (read user)
in
[(prog,emptyResults{compile_time = ct})];
Nothing ->
read_mut = read mut
read_gc = read gc
time = (read init + read_mut + read_gc) :: Float
- ct = addToFM emptyFM mod time
+ ct = Map.singleton mod time
in
[(prog,emptyResults{compile_time = ct})];
Nothing ->
read_mut = read mut
read_gc = read gc
time = (read init + read_mut + read_gc) :: Float
- ct = addToFM emptyFM mod time
+ ct = Map.singleton mod time
in
[(prog,emptyResults{compile_time = ct})];
Nothing ->
read_mut = read mut
read_gc = read gc
time = (read init + read_mut + read_gc) :: Float
- ct = addToFM emptyFM mod time
+ ct = Map.singleton mod time
in
[(prog,emptyResults{compile_time = ct})];
Nothing ->
read_mut = read mut
read_gc = read gc
time = (read init + read_mut + read_gc) :: Float
- ct = addToFM emptyFM mod time
+ ct = Map.singleton mod time
in
[(prog,emptyResults{compile_time = ct})];
Nothing ->
Just (read text + read datas),
compile_status = Success})]
| otherwise ->
- let ms = addToFM emptyFM mod (read text + read datas)
+ let ms = Map.singleton mod (read text + read datas)
in
[(prog,emptyResults{module_size = ms})]