summaryrefslogtreecommitdiff
path: root/utils/stat2resid/process-gcstats.prl
diff options
context:
space:
mode:
Diffstat (limited to 'utils/stat2resid/process-gcstats.prl')
-rw-r--r--utils/stat2resid/process-gcstats.prl45
1 files changed, 45 insertions, 0 deletions
diff --git a/utils/stat2resid/process-gcstats.prl b/utils/stat2resid/process-gcstats.prl
new file mode 100644
index 0000000000..ff41cf6af9
--- /dev/null
+++ b/utils/stat2resid/process-gcstats.prl
@@ -0,0 +1,45 @@
+#
+# Subroutines which derive information from
+# ghc garbage collection stats -- %gcstat
+#
+
+sub max_residency {
+ local(%gcstats) = @_;
+ local($i, $max) = (-1, 0);
+
+ if ($gcstats{"collector"} eq "APPEL") {
+ die "APPEL stats: average residency not possible\n" ;
+ }
+
+ while(++$i < $gcstats{"gc_no"}) {
+ $max = $gcstats{"live_$i"} > $max ?
+ $gcstats{"live_$i"} : $max;
+ }
+ $max;
+}
+
+sub avg_residency {
+ local(%gcstats) = @_;
+ local($i, $j, $total);
+
+ if ($gcstats{"collector"} eq "APPEL") {
+ die "APPEL stats: average residency not possible\n" ;
+ }
+
+ if ($gcstats{"gc_no"} == 0) { return(0); };
+
+ $i = 0; $j = 0;
+ $total = $gcstats{"live_$i"} * $gcstats{"mut_user_$i"} / 2;
+
+ while(++$i < $gcstats{"gc_no"}) {
+ $total += ($gcstats{"live_$i"} + $gcstats{"live_$j"})
+ * $gcstats{"mut_user_$i"} / 2;
+ $j = $i;
+ };
+
+ $total += $gcstats{"live_$j"} * $gcstats{"mut_user_$i"} / 2;
+
+ int($total / $gcstats{"mut_user_total"});
+}
+
+1;