X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fnofib-analyse%2FSlurp.hs;h=6fd7b47575e0e90eff3d6aa8c7298fed83f69ada;hb=aacb44f0de5a337171b1446cab3eaa73f978d480;hp=f775baee4fc0e165f4a47286ab96242e955bbd77;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/utils/nofib-analyse/Slurp.hs b/utils/nofib-analyse/Slurp.hs index f775bae..6fd7b47 100644 --- a/utils/nofib-analyse/Slurp.hs +++ b/utils/nofib-analyse/Slurp.hs @@ -4,18 +4,20 @@ -- ----------------------------------------------------------------------------- -module Slurp (Status(..), Results(..), ResultTable(..), parse_log) where +module Slurp (Status(..), Results(..), ResultTable, parse_log) where import CmdLine -import Data.FiniteMap -import RegexString + +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 @@ -27,8 +29,8 @@ data Status | 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], @@ -45,8 +47,8 @@ data Results = Results { } emptyResults = Results { - compile_time = emptyFM, - module_size = emptyFM, + compile_time = Map.empty, + module_size = Map.empty, binary_size = Nothing, link_time = Nothing, run_time = [], @@ -75,7 +77,8 @@ Various banner lines: ==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 @@ -126,10 +129,10 @@ parse_log . 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 @@ -149,8 +152,8 @@ 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, @@ -193,14 +196,14 @@ parse_compile_time prog mod [] = [] 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 -> @@ -211,7 +214,7 @@ parse_compile_time prog mod (l:ls) = 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 -> @@ -222,7 +225,7 @@ parse_compile_time prog mod (l:ls) = 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 -> @@ -233,7 +236,7 @@ parse_compile_time prog mod (l:ls) = 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 -> @@ -244,7 +247,7 @@ parse_compile_time prog mod (l:ls) = 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 -> @@ -367,7 +370,7 @@ parse_size prog mod (l:ls) = 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})]