2 # (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 # Perl script expect bindings for the following variables to be prepended
6 # DEFAULT_TMPDIR libdir
8 # without them, not much success :-(
11 $debug = 0; # first line of script, builds confidence :-)
12 $outsuffix = ".resid.ps"; # change as appropriate
14 if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
15 $tmpfile = $ENV{'TMPDIR'} . "/$$.resid.data";
17 $tmpfile ="${DEFAULT_TMPDIR}/$$.resid.data";
18 $ENV{'TMPDIR'} = ${DEFAULT_TMPDIR}; # set the env var as well
23 require('parse-gcstats.prl') || die "Can't load parse-gcstats.prl!\n";
24 require('process-gcstats.prl') || die "Can't load process-gcstats.prl!\n";
28 $outfile = ""; # gnuplot: set output
29 } elsif ($#ARGV == 0) {
31 if ($infile =~ /^(.*)\.stat$/) {
35 $infile = "$base.stat";
37 $outfile = "\"$base$outsuffix\""; # gnuplot: set output "outfile"
38 } elsif ($#ARGV == 1) {
40 $outfile = "\"$ARGV[1]\"";
42 die "Usage: command [infile[.stat] [outfile]]";
45 %gcstats = &parse_stats($infile);
47 &print_stats(">&STDERR", %gcstats) if $debug;
49 if ($gcstats{"collector"} eq "APPEL") {
50 die "APPEL stats: no residency plot possible\n";
54 # stats are now loaded into %gcstats -- write out info
57 open(DATAFILE, ">$tmpfile") || die "Cant open >$tmpfile \n";
60 printf DATAFILE "%4.2f %d\n", $user, 0;
61 while (++$i < $gcstats{"gc_no"}) {
62 $user += $gcstats{"mut_user_$i"};
63 printf DATAFILE "%4.2f %d\n", $user, $gcstats{"live_$i"};
65 printf DATAFILE "%4.2f %d\n", $gcstats{"mut_user_total"}, 0;
68 open(PLOTFILE, "|gnuplot") || die "Cant pipe into |gnuplot \n";
69 print PLOTFILE "set data style linespoints\n";
70 print PLOTFILE "set function style lines\n";
71 print PLOTFILE "set nokey\n";
72 print PLOTFILE "set xlabel \"Mutator Time (secs)\"\n";
73 print PLOTFILE "set ylabel \"Heap Residency (bytes)\" 0,-1\n";
74 print PLOTFILE "set term post eps \"Times-Roman\" 20\n";
75 printf PLOTFILE "set title \"%s %s (%s)\"\n", $gcstats{"command"}, $gcstats{"args"}, $infile;
76 print PLOTFILE "set output $outfile\n" ;
77 print PLOTFILE "plot \"$tmpfile\"\n";