Commit 1fabd032 authored by Simon Marlow's avatar Simon Marlow

compute means of total-heap-size and allocations

parent c6ee1d8d
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
-- All the code below is understood to be in the public domain. -- All the code below is understood to be in the public domain.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
> {-# LANGUAGE CPP #-}
> module GenUtils ( > module GenUtils (
> partition', tack, > partition', tack,
......
{-# LANGUAGE RankNTypes, ExistentialQuantification #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- $Id: Main.hs,v 1.10 2005/06/07 10:58:31 simonmar Exp $
-- (c) Simon Marlow 1997-2005 -- (c) Simon Marlow 1997-2005
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
...@@ -119,7 +118,7 @@ size_spec, alloc_spec, runtime_spec, elapsedtime_spec, muttime_spec, mutetime_sp ...@@ -119,7 +118,7 @@ size_spec, alloc_spec, runtime_spec, elapsedtime_spec, muttime_spec, mutetime_sp
gc0time_spec, gc0elap_spec, gc1time_spec, gc1elap_spec, balance_spec, totmem_spec gc0time_spec, gc0elap_spec, gc1time_spec, gc1elap_spec, balance_spec, totmem_spec
:: PerProgTableSpec :: PerProgTableSpec
size_spec = SpecP "Binary Sizes" "Size" "binary-sizes" binary_size compile_status always_ok size_spec = SpecP "Binary Sizes" "Size" "binary-sizes" binary_size compile_status always_ok
alloc_spec = SpecP "Allocations" "Allocs" "allocations" allocs run_status always_ok alloc_spec = SpecP "Allocations" "Allocs" "allocations" (meanInt allocs) run_status always_ok
runtime_spec = SpecP "Run Time" "Runtime" "run-times" (mean run_time) run_status time_ok runtime_spec = SpecP "Run Time" "Runtime" "run-times" (mean run_time) run_status time_ok
elapsedtime_spec = SpecP "Elapsed Time" "Elapsed" "elapsed-times" (mean elapsed_time) run_status time_ok elapsedtime_spec = SpecP "Elapsed Time" "Elapsed" "elapsed-times" (mean elapsed_time) run_status time_ok
muttime_spec = SpecP "Mutator Time" "MutTime" "mutator-time" (mean mut_time) run_status time_ok muttime_spec = SpecP "Mutator Time" "MutTime" "mutator-time" (mean mut_time) run_status time_ok
...@@ -136,7 +135,7 @@ instrs_spec = SpecP "Instructions" "Instrs" "instrs" instrs run_status always_o ...@@ -136,7 +135,7 @@ instrs_spec = SpecP "Instructions" "Instrs" "instrs" instrs run_status always_o
mreads_spec = SpecP "Memory Reads" "Reads" "mem-reads" mem_reads run_status always_ok mreads_spec = SpecP "Memory Reads" "Reads" "mem-reads" mem_reads run_status always_ok
mwrite_spec = SpecP "Memory Writes" "Writes" "mem-writes" mem_writes run_status always_ok mwrite_spec = SpecP "Memory Writes" "Writes" "mem-writes" mem_writes run_status always_ok
cmiss_spec = SpecP "Cache Misses" "Misses" "cache-misses" cache_misses run_status always_ok cmiss_spec = SpecP "Cache Misses" "Misses" "cache-misses" cache_misses run_status always_ok
totmem_spec = SpecP "Total Memory in use" "TotalMem" "total-mem" total_memory run_status always_ok totmem_spec = SpecP "Total Memory in use" "TotalMem" "total-mem" (meanInt total_memory) run_status always_ok
all_specs :: [PerProgTableSpec] all_specs :: [PerProgTableSpec]
all_specs = [ all_specs = [
...@@ -174,6 +173,11 @@ mean f results = go (f results) ...@@ -174,6 +173,11 @@ mean f results = go (f results)
where go [] = Nothing where go [] = Nothing
go fs = Just (foldl' (+) 0 fs / fromIntegral (length fs)) go fs = Just (foldl' (+) 0 fs / fromIntegral (length fs))
meanInt :: Integral a => (Results -> [a]) -> Results -> Maybe a
meanInt f results = go (f results)
where go [] = Nothing
go fs = Just (foldl' (+) 0 fs `quot` fromIntegral (length fs))
-- Look for bogus-looking times: On Linux we occasionally get timing results -- Look for bogus-looking times: On Linux we occasionally get timing results
-- that are bizarrely low, and skew the average. -- that are bizarrely low, and skew the average.
checkTimes :: String -> Results -> IO () checkTimes :: String -> Results -> IO ()
...@@ -843,8 +847,10 @@ showBox (Percentage f) = case printf "%.1f%%" (f-100) of ...@@ -843,8 +847,10 @@ showBox (Percentage f) = case printf "%.1f%%" (f-100) of
xs@('-':_) -> xs xs@('-':_) -> xs
xs -> '+':xs xs -> '+':xs
showBox (BoxFloat f) = printf "%.2f" f showBox (BoxFloat f) = printf "%.2f" f
showBox (BoxInt n) = show (n `div` 1024) ++ "k" showBox (BoxInt n) = show (n `div` (1024*1024))
showBox (BoxInteger n) = show (n `div` 1024) ++ "k" showBox (BoxInteger n) = show (n `div` (1024*1024))
--showBox (BoxInt n) = show (n `div` 1024) ++ "k"
--showBox (BoxInteger n) = show (n `div` 1024) ++ "k"
showBox (BoxString s) = s showBox (BoxString s) = s
instance Show BoxValue where instance Show BoxValue where
......
...@@ -47,10 +47,10 @@ data Results = Results { ...@@ -47,10 +47,10 @@ data Results = Results {
gc1_time :: [Float], gc1_time :: [Float],
gc1_elapsed_time :: [Float], gc1_elapsed_time :: [Float],
balance :: [Float], balance :: [Float],
allocs :: Maybe Integer, allocs :: [Integer],
run_status :: Status, run_status :: Status,
compile_status :: Status, compile_status :: Status,
total_memory :: Maybe Integer total_memory :: [Integer]
} }
emptyResults :: Results emptyResults :: Results
...@@ -75,10 +75,10 @@ emptyResults = Results { ...@@ -75,10 +75,10 @@ emptyResults = Results {
gc1_elapsed_time = [], gc1_elapsed_time = [],
balance = [], balance = [],
gc_work = Nothing, gc_work = Nothing,
allocs = Nothing, allocs = [],
compile_status = NotDone, compile_status = NotDone,
run_status = NotDone, run_status = NotDone,
total_memory = Nothing total_memory = []
} }
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
...@@ -250,10 +250,10 @@ combine2Results ...@@ -250,10 +250,10 @@ combine2Results
balance = b1 ++ b2, balance = b1 ++ b2,
gc_work = gw1 `mplus` gw2, gc_work = gw1 `mplus` gw2,
binary_size = bs1 `mplus` bs2, binary_size = bs1 `mplus` bs2,
allocs = al1 `mplus` al2, allocs = al1 ++ al2,
run_status = combStatus rs1 rs2, run_status = combStatus rs1 rs2,
compile_status = combStatus cs1 cs2, compile_status = combStatus cs1 cs2,
total_memory = tm1 `mplus` tm2 } total_memory = tm1 ++ tm2 }
combStatus :: Status -> Status -> Status combStatus :: Status -> Status -> Status
combStatus NotDone y = y combStatus NotDone y = y
...@@ -357,20 +357,20 @@ parse_run_time prog (l:ls) res ex = ...@@ -357,20 +357,20 @@ parse_run_time prog (l:ls) res ex =
case ghc1_re l of { case ghc1_re l of {
Just (allocations, _, _, _, _, _, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed) -> Just (allocations, _, _, _, _, _, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed) ->
got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed [] [] [] [] [] got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed [] [] [] [] []
Nothing Nothing Nothing Nothing Nothing Nothing; Nothing Nothing Nothing Nothing Nothing [];
Nothing -> Nothing ->
case ghc2_re l of { case ghc2_re l of {
Just (allocations, _, _, _, _, in_use, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed) -> Just (allocations, _, _, _, _, in_use, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed) ->
got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed [] [] [] [] [] got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed [] [] [] [] []
Nothing Nothing Nothing Nothing Nothing (Just in_use); Nothing Nothing Nothing Nothing Nothing [in_use];
Nothing -> Nothing ->
case ghc3_re l of { case ghc3_re l of {
Just (allocations, _, _, _, _, gc_work', in_use, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed) -> Just (allocations, _, _, _, _, gc_work', in_use, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed) ->
got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed [] [] [] [] [] got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed [] [] [] [] []
(Just gc_work') Nothing Nothing Nothing Nothing (Just in_use); (Just gc_work') Nothing Nothing Nothing Nothing [in_use];
Nothing -> Nothing ->
...@@ -378,7 +378,7 @@ parse_run_time prog (l:ls) res ex = ...@@ -378,7 +378,7 @@ parse_run_time prog (l:ls) res ex =
Just (allocations, _, _, _, _, gc_work', in_use, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed, is, mem_rs, mem_ws, cache_misses') -> Just (allocations, _, _, _, _, gc_work', in_use, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed, is, mem_rs, mem_ws, cache_misses') ->
got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed [] [] [] [] [] got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed [] [] [] [] []
(Just gc_work') (Just is) (Just mem_rs) (Just gc_work') (Just is) (Just mem_rs)
(Just mem_ws) (Just cache_misses') (Just in_use); (Just mem_ws) (Just cache_misses') [in_use];
Nothing -> Nothing ->
...@@ -386,7 +386,7 @@ parse_run_time prog (l:ls) res ex = ...@@ -386,7 +386,7 @@ parse_run_time prog (l:ls) res ex =
Just (allocations, _, _, _, _, gc_work', in_use, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed, gc0, gc0_elapsed, gc1, gc1_elapsed, bal) -> Just (allocations, _, _, _, _, gc_work', in_use, initialisation, init_elapsed, mut, mut_elapsed, gc, gc_elapsed, gc0, gc0_elapsed, gc1, gc1_elapsed, bal) ->
got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed got_run_result allocations initialisation init_elapsed mut mut_elapsed gc gc_elapsed
[gc0] [gc0_elapsed] [gc1] [gc1_elapsed] [bal] [gc0] [gc0_elapsed] [gc1] [gc1_elapsed] [bal]
(Just gc_work') Nothing Nothing Nothing Nothing (Just in_use); (Just gc_work') Nothing Nothing Nothing Nothing [in_use];
Nothing -> Nothing ->
...@@ -435,7 +435,7 @@ parse_run_time prog (l:ls) res ex = ...@@ -435,7 +435,7 @@ parse_run_time prog (l:ls) res ex =
gc1_elapsed_time = gc1_elapsed, gc1_elapsed_time = gc1_elapsed,
balance = bal, balance = bal,
gc_work = gc_work', gc_work = gc_work',
allocs = Just allocations, allocs = [allocations],
instrs = instrs', instrs = instrs',
mem_reads = mem_rs, mem_reads = mem_rs,
mem_writes = mem_ws, mem_writes = mem_ws,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment