@PgmArgs = ();
$PgmExitStatus = 0;
$PgmStdinFile = '/dev/null';
-$TmpPrefix = '$(TMPDIR)';
+if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
+ $TmpPrefix = $ENV{'TMPDIR'};
+} else {
+ $TmpPrefix ="$(TMPDIR)";
+ $ENV{'TMPDIR'} = '$(TMPDIR)'; # set the env var as well
+}
$ScriptFile = "$TmpPrefix/run_me$$";
$DefaultStdoutFile = "$TmpPrefix/no_stdout$$"; # can't use /dev/null (e.g. Alphas)
$DefaultStderrFile = "$TmpPrefix/no_stderr$$";
arg: while ($_ = $ARGV[0]) {
shift(@ARGV);
+ /^--$/ && do { # let anything past after --
+ push(@PgmArgs, @ARGV);
+ last arg; };
+
/^-v$/ && do { $Verbose = 1; next arg; };
/^-O(.*)/ && do { push(@PgmArgs, &grab_arg_arg('-O',$1)); next arg; };
/^-i(.*)/ && do { $PgmStdinFile = &grab_arg_arg('-i',$1);
next arg; };
/^-postscript(.*)/ && do { $PostScript = &grab_arg_arg('-postscript',$1);
next arg; };
+ /^-script/ && do { print STDERR "$Pgm: -script argument is obsolete;\nUse -prescript and -postscript instead.\n";
+ $Status++;
+ next arg; };
/^-(ghc|hbc)-timing$/ && do { $SysSpecificTiming = $1;
next arg; };
/^-spix-timing$/ && do { $SysSpecificTiming = 'ghcspix';
open(SPIXNM, "nm -n $ToRunOrig |") || die "nm -n $ToRunOrig open failed!\n";
spix: while (<SPIXNM>) {
- if ( / T (_FreeMallocPtr|_([A-Za-z]+)Hook|_xmalloc|_mpz_get_si)$/ ) {
+ if ( / T +(_freeForeignObj|_([A-Za-z]+)Hook|_xmalloc|_mpz_get_si)$/ ) {
$LastSpix = $1;
last spix;
}
#NB: nearly the same as in GHC driver's -ghc-timing stuff
open(STATS, $StatsFile) || die "Failed when opening $StatsFile\n";
- local($tot_live) = 0; # for calculating avg residency
+
+ local($max_live) = 0;
+ local($tot_live) = 0; # for calculating residency stuff
+ local($tot_samples) = 0;
while (<STATS>) {
- $tot_live += $1 if /^\s*\d+\s+\d+\s+\d+\.\d+\%\s+(\d+)\s+\d+\.\d+\%/;
+ if (! /Minor/ && /^\s*\d+\s+\d+\s+(\d+)\s+\d+\.\d+\%/ ) {
+ $max_live = $1 if $max_live < $1;
+ $tot_live += $1;
+ $tot_samples += 1;
+ }
$BytesAlloc = $1 if /^\s*([0-9,]+) bytes allocated in the heap/;
- if ( /^\s*([0-9,]+) bytes maximum residency .* (\d+) sample/ ) {
- $MaxResidency = $1; $ResidencySamples = $2;
- }
+# if ( /^\s*([0-9,]+) bytes maximum residency .* (\d+) sample/ ) {
+# $MaxResidency = $1; $ResidencySamples = $2;
+# }
$GCs = $1 if /^\s*([0-9,]+) garbage collections? performed/;
}
}
close(STATS) || die "Failed when closing $StatsFile\n";
- if ( defined($ResidencySamples) && $ResidencySamples > 0 ) {
- $AvgResidency = int ($tot_live / $ResidencySamples) ;
+ if ( $tot_samples > 0 ) {
+ $ResidencySamples = $tot_samples;
+ $MaxResidency = $max_live;
+ $AvgResidency = int ($tot_live / $tot_samples) ;
}
} elsif ( $SysSpecificTiming eq 'hbc' ) {