2 # (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 # Perl script expect bindings for the following variables to be prepended
10 $outsuffix = ".resid.ps"; # change as appropriate
12 if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
13 $tmpfile = $ENV{'TMPDIR'} . "/$$.resid.data";
15 $tmpfile ="${TMPDIR}/$$.resid.data";
16 $ENV{'TMPDIR'} = ${TMPDIR}; # set the env var as well
19 @INC = ( ${SCRIPT_PATH} );
21 require('parse-gcstats.prl') || die "Can't load parse-gcstats.prl!\n";
22 require('process-gcstats.prl') || die "Can't load process-gcstats.prl!\n";
26 $outfile = ""; # gnuplot: set output
27 } elsif ($#ARGV == 0) {
29 if ($infile =~ /^(.*)\.stat$/) {
33 $infile = "$base.stat";
35 $outfile = "\"$base$outsuffix\""; # gnuplot: set output "outfile"
36 } elsif ($#ARGV == 1) {
38 $outfile = "\"$ARGV[1]\"";
40 die "Usage: command [infile[.stat] [outfile]]";
43 %gcstats = &parse_stats($infile);
45 &print_stats(">&STDERR", %gcstats) if $debug;
47 if ($gcstats{"collector"} eq "APPEL") {
48 die "APPEL stats: no residency plot possible\n";
52 # stats are now loaded into %gcstats -- write out info
55 open(DATAFILE, ">$tmpfile") || die "Cant open >$tmpfile \n";
58 printf DATAFILE "%4.2f %d\n", $user, 0;
59 while (++$i < $gcstats{"gc_no"}) {
60 $user += $gcstats{"mut_user_$i"};
61 printf DATAFILE "%4.2f %d\n", $user, $gcstats{"live_$i"};
63 printf DATAFILE "%4.2f %d\n", $gcstats{"mut_user_total"}, 0;
66 open(PLOTFILE, "|gnuplot") || die "Cant pipe into |gnuplot \n";
67 print PLOTFILE "set data style linespoints\n";
68 print PLOTFILE "set function style lines\n";
69 print PLOTFILE "set nokey\n";
70 print PLOTFILE "set xlabel \"Mutator Time (secs)\"\n";
71 print PLOTFILE "set ylabel \"Heap Residency (bytes)\" 0,-1\n";
72 print PLOTFILE "set term post eps \"Times-Roman\" 20\n";
73 printf PLOTFILE "set title \"%s %s (%s)\"\n", $gcstats{"command"}, $gcstats{"args"}, $infile;
74 print PLOTFILE "set output $outfile\n" ;
75 print PLOTFILE "plot \"$tmpfile\"\n";