[project @ 2003-07-10 08:02:29 by simonpj]
[ghc-hetmet.git] / glafp-utils / nofib-analyse / Slurp.hs
index 92a0529..5fe15dd 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: Slurp.hs,v 1.1 1999/11/12 11:54:17 simonmar Exp $
+-- $Id: Slurp.hs,v 1.4 2002/09/18 12:36:40 simonmar Exp $
 
 -- (c) Simon Marlow 1997-1999
 -----------------------------------------------------------------------------
@@ -35,6 +35,7 @@ data Results = Results {
        instrs          :: Maybe Integer,
        mem_reads       :: Maybe Integer,
        mem_writes      :: Maybe Integer,
+       cache_misses    :: Maybe Integer,
        gc_work         :: Maybe Integer,
        gc_time         :: Maybe Float,
        allocs          :: Maybe Integer,
@@ -52,6 +53,7 @@ emptyResults = Results {
        instrs          = Nothing,
        mem_reads       = Nothing,
        mem_writes      = Nothing,
+       cache_misses    = Nothing,
        gc_time         = Nothing,
        gc_work         = Nothing,
        allocs          = Nothing,
@@ -81,6 +83,10 @@ of "time" will need different regexps.
 
 time_re = mkRegex "^[ \t]*([0-9.]+)[ \t]+real[ \t]+([0-9.]+)[ \t]+user[ \t]+([0-9.]+)[ \t]+sys[ \t]*$"
 
+time_gnu17_re = mkRegex "^[ \t]*([0-9.]+)user[ \t]+([0-9.]+)system[ \t]+([0-9.:]+)elapsed"
+                -- /usr/bin/time --version reports: GNU time 1.7
+                -- notice the order is different, and the elapsed time is [hh:]mm:ss.s
+
 size_re = mkRegex "^[ \t]*([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)"
 
 {-
@@ -100,7 +106,7 @@ ghc2_re = mkRegex "^<<ghc:[ \t]+([0-9]+)[ \t]+bytes,[ \t]*([0-9]+)[ \t]+GCs,[ \t
 
 ghc3_re = mkRegex "^<<ghc:[ \t]+([0-9]+)[ \t]+bytes,[ \t]*([0-9]+)[ \t]+GCs,[ \t]*([0-9]+)/([0-9]+)[ \t]+avg/max bytes residency \\(([0-9]+) samples\\), ([0-9]+) bytes GC work, ([0-9]+)M in use, ([0-9.]+) INIT \\(([0-9.]+) elapsed\\), ([0-9.]+) MUT \\(([0-9.]+) elapsed\\), ([0-9.]+) GC \\(([0-9.]+) elapsed\\) :ghc>>"
 
-ghc4_re = mkRegex "^<<ghc-instrs:[ \t]+([0-9]+)[ \t]+bytes,[ \t]*([0-9]+)[ \t]+GCs,[ \t]*([0-9]+)/([0-9]+)[ \t]+avg/max bytes residency \\(([0-9]+) samples\\), ([0-9]+) bytes GC work, ([0-9]+)M in use, ([0-9.]+) INIT \\(([0-9.]+) elapsed\\), ([0-9.]+) MUT \\(([0-9.]+) elapsed\\), ([0-9.]+) GC \\(([0-9.]+) elapsed\\), ([0-9]+) instructions, ([0-9]+) memory reads, ([0-9]+) memory writes :ghc-instrs>>"
+ghc4_re = mkRegex "^<<ghc-instrs:[ \t]+([0-9]+)[ \t]+bytes,[ \t]*([0-9]+)[ \t]+GCs,[ \t]*([0-9]+)/([0-9]+)[ \t]+avg/max bytes residency \\(([0-9]+) samples\\), ([0-9]+) bytes GC work, ([0-9]+)M in use, ([0-9.]+) INIT \\(([0-9.]+) elapsed\\), ([0-9.]+) MUT \\(([0-9.]+) elapsed\\), ([0-9.]+) GC \\(([0-9.]+) elapsed\\), ([0-9]+) instructions, ([0-9]+) memory reads, ([0-9]+) memory writes, ([0-9]+) L2 cache misses :ghc-instrs>>"
 
 wrong_exit_status = mkRegex "^\\**[ \t]*expected exit status ([0-9]+) not seen ; got ([0-9]+)"
 
@@ -127,6 +133,7 @@ combine_results = foldr f emptyFM
                      module_size = ms1,
                      run_time = rt1, mut_time = mt1, 
                      instrs = is1, mem_reads = mr1, mem_writes = mw1,
+                     cache_misses = cm1,
                      gc_time = gt1, gc_work = gw1,
                      binary_size = bs1, allocs = al1, 
                      run_status = rs1, compile_status = cs1 }
@@ -134,6 +141,7 @@ combine_results = foldr f emptyFM
                      module_size = ms2,
                      run_time = rt2, mut_time = mt2,
                      instrs = is2, mem_reads = mr2, mem_writes = mw2,
+                     cache_misses = cm2,
                      gc_time = gt2, gc_work = gw2,
                      binary_size = bs2, allocs = al2, 
                      run_status = rs2, compile_status = cs2 }
@@ -145,6 +153,7 @@ combine_results = foldr f emptyFM
                      instrs         = combMaybes is1 is2,
                      mem_reads      = combMaybes mr1 mr2,
                      mem_writes     = combMaybes mw1 mw2,
+                     cache_misses   = combMaybes cm1 cm2,
                      gc_time        = combMaybes gt1 gt2,
                      gc_work        = combMaybes gw1 gw2,
                      binary_size    = combMaybes bs1 bs2,
@@ -185,6 +194,13 @@ parse_compile_time prog mod (l:ls) =
                [(prog,emptyResults{compile_time = ct})];
             Nothing -> 
 
+       case matchRegex time_gnu17_re l of {
+            Just (user:system:elapsed:_) ->
+               let ct  = addToFM emptyFM mod (read user)
+               in 
+               [(prog,emptyResults{compile_time = ct})];
+            Nothing -> 
+
        case matchRegex ghc1_re l of {
            Just (allocs:_:_:_:_:init:_:mut:_:gc:_) ->
              let 
@@ -230,14 +246,22 @@ parse_compile_time prog mod (l:ls) =
            Nothing ->
 
                parse_compile_time prog mod ls
-       }}}}}
+       }}}}}}
 
 parse_link_time prog [] = []
 parse_link_time prog (l:ls) =
-         case matchRegex time_re l of
-            Nothing -> parse_link_time prog ls
+         case matchRegex time_re l of {
             Just (real:user:system:_) ->
-               [(prog,emptyResults{link_time = Just (read user)})]
+               [(prog,emptyResults{link_time = Just (read user)})];
+            Nothing ->
+
+         case matchRegex time_gnu17_re l of {
+            Just (user:system:elapsed:_) ->
+               [(prog,emptyResults{link_time = Just (read user)})];
+            Nothing ->
+
+          parse_link_time prog ls
+          }}
 
 parse_run_time prog [] NotDone = []
 parse_run_time prog [] ex =[(prog,emptyResults{run_status=ex})]
@@ -287,7 +311,7 @@ parse_run_time prog (l:ls) ex =
            Nothing ->
        
        case matchRegex ghc4_re l of {
-          Just (allocs:_:_:_:_:gc_work:_:init:_:mut:_:gc:_:is:mem_rs:mem_ws:_) ->
+          Just (allocs:_:_:_:_:gc_work:_:init:_:mut:_:gc:_:is:mem_rs:mem_ws:cache_misses:_) ->
              let 
                  read_mut = read mut
                  read_gc  = read gc
@@ -299,8 +323,9 @@ parse_run_time prog (l:ls) ex =
                                  gc_work    = Just read_gc_work,
                                  gc_time    = Just read_gc,
                                  instrs     = Just (read is),
-                                 mem_writes = Just (read mem_ws),
                                  mem_reads  = Just (read mem_rs),
+                                 mem_writes = Just (read mem_ws),
+                                 cache_misses = Just (read cache_misses),
                                  allocs     = Just (read allocs),
                                  run_status = Success })];
            Nothing ->
@@ -348,7 +373,7 @@ parse_size prog mod (l:ls) =
                                              Just (read text + read datas),
                                    compile_status = Success})]
                 | otherwise ->
-                       let ms  = addToFM emptyFM mod (read text)
+                       let ms  = addToFM emptyFM mod (read text + read datas)
                        in
                        [(prog,emptyResults{module_size = ms})]