Fix scoped type variables for expression type signatures
[ghc-hetmet.git] / utils / stat2resid / process-gcstats.prl
1 #
2 # Subroutines which derive information from
3 #   ghc garbage collection stats -- %gcstat
4 #
5
6 sub max_residency {
7     local(%gcstats) = @_;
8     local($i, $max) = (-1, 0);
9
10     if ($gcstats{"collector"} eq "APPEL") {
11         die "APPEL stats: average residency not possible\n" ;
12     }
13
14     while(++$i < $gcstats{"gc_no"}) {
15         $max = $gcstats{"live_$i"} > $max ?
16                    $gcstats{"live_$i"} : $max;
17     }
18     $max;
19 }
20
21 sub avg_residency {
22     local(%gcstats) = @_;
23     local($i, $j, $total);
24
25     if ($gcstats{"collector"} eq "APPEL") {
26         die "APPEL stats: average residency not possible\n" ;
27     }
28
29     if ($gcstats{"gc_no"} == 0) { return(0); };
30
31     $i = 0; $j = 0;
32     $total = $gcstats{"live_$i"} * $gcstats{"mut_user_$i"} / 2;
33
34     while(++$i < $gcstats{"gc_no"}) {
35         $total += ($gcstats{"live_$i"} + $gcstats{"live_$j"})
36                  * $gcstats{"mut_user_$i"} / 2;
37         $j = $i;
38     };
39
40     $total += $gcstats{"live_$j"} * $gcstats{"mut_user_$i"} / 2;
41
42     int($total / $gcstats{"mut_user_total"});
43 }
44
45 1;