X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=glafp-utils%2Frunstdtest%2Frunstdtest.prl;h=e6a3534b1e16f1da67e9ddfcd9b831bfef68dc21;hb=abbc5a0be1df84a33015470319062ed7a3aa3153;hp=a1719a379ac88c9a603aaa1550ecc39b14213a6f;hpb=f8997cd46f1311039dff83912b8988ff1b535e69;p=ghc-hetmet.git diff --git a/glafp-utils/runstdtest/runstdtest.prl b/glafp-utils/runstdtest/runstdtest.prl index a1719a3..e6a3534 100644 --- a/glafp-utils/runstdtest/runstdtest.prl +++ b/glafp-utils/runstdtest/runstdtest.prl @@ -2,7 +2,7 @@ # The perl script requires the following variables to be bound # to something meaningful before it will operate correctly: # -# TMPDIR +# DEFAULT_TMPDIR # CONTEXT_DIFF # RM # @@ -51,8 +51,8 @@ $PgmStdinFile = '/dev/null'; if ( $ENV{'TMPDIR'} ) { # where to make tmp file names $TmpPrefix = $ENV{'TMPDIR'}; } else { - $TmpPrefix ="$TMPDIR"; - $ENV{'TMPDIR'} = "$TMPDIR"; # set the env var as well + $TmpPrefix ="$DEFAULT_TMPDIR"; + $ENV{'TMPDIR'} = "$DEFAULT_TMPDIR"; # set the env var as well } $ScriptFile = "$TmpPrefix/run_me$$"; $DefaultStdoutFile = "$TmpPrefix/no_stdout$$"; # can't use /dev/null (e.g. Alphas) @@ -63,14 +63,14 @@ $PreScript = ''; $PostScript = ''; $TimeCmd = ''; $StatsFile = "$TmpPrefix/stats$$"; -$CacheProfStats = "cacheprof.out.summary"; +$CachegrindStats = "cachegrind.out.summary"; $SysSpecificTiming = ''; -$CacheProf = 'no'; +$Cachegrind = 'no'; die "$Pgm: program to run not given as first argument\n" if $#ARGV < 0; $ToRun = $ARGV[0]; shift(@ARGV); # avoid picking up same-named thing from somewhere else on $PATH... -$ToRun = "./$ToRun" if $ToRun !~ /^\//; +$ToRun = "./$ToRun" if -e "./$ToRun"; arg: while ($_ = $ARGV[0]) { shift(@ARGV); @@ -111,9 +111,9 @@ arg: while ($_ = $ARGV[0]) { next arg; }; /^-(ghc|hbc)-timing$/ && do { $SysSpecificTiming = $1; next arg; }; - /^-cacheprof$/ && do { $SysSpecificTiming = 'ghc-instrs'; - $CacheProf = 'yes'; - next arg }; + /^-cachegrind$/ && do { $SysSpecificTiming = 'ghc-instrs'; + $Cachegrind = 'yes'; + next arg }; /^-t(.*)/ && do { $TimeCmd = &grab_arg_arg('-t', $1); next arg; }; # anything else is taken to be a pgm arg @@ -167,6 +167,7 @@ if ( $SysSpecificTiming =~ /^ghc/ ) { if ($PreScript ne '') { local($to_do); $PreScriptLines = `cat $PreScript`; + $PreScriptLines =~ s/\r//g; } else { $PreScriptLines = ''; } @@ -174,6 +175,7 @@ if ($PreScript ne '') { if ($PostScript ne '') { local($to_do); $PostScriptLines = `cat $PostScript`; + $PostScriptLines =~ s/\r//g; $* = 1; $PostScriptLines =~ s#\$o1#$TmpPrefix/runtest$$.1#g; $PostScriptLines =~ s#\$o2#$TmpPrefix/runtest$$.2#g; @@ -183,6 +185,12 @@ if ($PostScript ne '') { # OK, so we're gonna do the normal thing... +if ($Cachegrind eq 'yes') { + $CachegrindPrefix = "cachegrind --logfile-fd=99 99>$CachegrindStats"; +} else { + $CachegrindPrefix = ''; +} + $Script = < $DefaultStdoutFile cat /dev/null > $DefaultStderrFile $PreScriptLines $SpixifyLine1 -$TimeCmd /bin/sh -c \'$ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> $TmpPrefix/runtest$$.1 2> $TmpPrefix/runtest$$.2 3> $TmpPrefix/runtest$$.3\' +echo $TimeCmd /bin/sh -c \'$CachegrindPrefix $ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> $TmpPrefix/runtest$$.1 2> $TmpPrefix/runtest$$.2 3> $TmpPrefix/runtest$$.3\' +$TimeCmd /bin/sh -c \'$CachegrindPrefix $ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> $TmpPrefix/runtest$$.1 2> $TmpPrefix/runtest$$.2 3> $TmpPrefix/runtest$$.3\' progexit=\$? if [ \$progexit -eq 0 ] && [ $PgmFail -ne 0 ]; then echo $ToRun @PgmArgs \\< $PgmStdinFile @@ -230,8 +239,6 @@ else cp $TmpPrefix/runtest$$.1 $PgmStdoutFile[0] fi fi -egrep -v '^ld\.so:.*has older revision than expected' < $TmpPrefix/runtest$$.2 > $TmpPrefix/runtest$$.2b -mv -f $TmpPrefix/runtest$$.2b $TmpPrefix/runtest$$.2 hit='NO' for out_file in @PgmStderrFile ; do @@ -279,14 +286,14 @@ if ( $SysSpecificTiming eq '' ) { } &process_stats_file(); -&process_cacheprof_files() if $CacheProf eq 'yes'; +&process_cachegrind_files() if $Cachegrind eq 'yes'; # print out what we found print STDERR "<<$SysSpecificTiming: "; -if ( $CacheProf ne 'yes' ) { +if ( $Cachegrind ne 'yes') { print STDERR "$BytesAlloc bytes, $GCs GCs, $AvgResidency/$MaxResidency avg/max bytes residency ($ResidencySamples samples), $GCWork bytes GC work, ${TotMem}M in use, $InitTime INIT ($InitElapsed elapsed), $MutTime MUT ($MutElapsed elapsed), $GcTime GC ($GcElapsed elapsed)"; } else { - print STDERR "$BytesAlloc bytes, $GCs GCs, $AvgResidency/$MaxResidency avg/max bytes residency ($ResidencySamples samples), $GCWork bytes GC work, ${TotMem}M in use, $InitTime INIT ($InitElapsed elapsed), $MutTime MUT ($MutElapsed elapsed), $GcTime GC ($GcElapsed elapsed), $TotInstrs instructions, $TotReads memory reads, $TotWrites memory writes"; + print STDERR "$BytesAlloc bytes, $GCs GCs, $AvgResidency/$MaxResidency avg/max bytes residency ($ResidencySamples samples), $GCWork bytes GC work, ${TotMem}M in use, $InitTime INIT ($InitElapsed elapsed), $MutTime MUT ($MutElapsed elapsed), $GcTime GC ($GcElapsed elapsed), $TotInstrs instructions, $TotReads memory reads, $TotWrites memory writes, $TotMisses L2 cache misses"; }; print STDERR " :$SysSpecificTiming>>\n"; @@ -298,7 +305,7 @@ exit 0; sub grab_arg_arg { local($option, $rest_of_arg) = @_; - if ($rest_of_arg) { + if ($rest_of_arg ne "") { return($rest_of_arg); } elsif ($#ARGV >= 0) { local($temp) = $ARGV[0]; shift(@ARGV); @@ -431,26 +438,30 @@ sub process_stats_file { $MutElapsed =~ s/,//g; $GcTime =~ s/,//g; $GcElapsed =~ s/,//g; - - # if timings are negative (I've seen -0.00s) then set to 0 - $InitTime = 0 unless $InitTime >= 0; - $InitElapsed = 0 unless $InitElapsed >= 0; - $MutTime = 0 unless $MutTime >= 0; - $MutElapsed = 0 unless $MutElapsed >= 0; - $GcTime = 0 unless $GcTime >= 0; - $GcElapsed = 0 unless $GcElapsed >= 0; - } -sub process_cacheprof_files { +sub process_cachegrind_files { + + open(STATS, "< $CachegrindStats") || die("Can't open $CachegrindStats\n"); - open(STATS, "< $CacheProfStats") || die("Can't open $CacheProfStats\n"); while () { - /OTHER\(\s*([0-9]+),\s*([0-9]+),\s*([0-9]+)\)/ && do { + /^==\d+==\s+I\s+refs:\s+([0-9,]*)/ && do { $TotInstrs = $1; - $TotReads = $2; - $TotWrites = $3; - } - } - close(STATS); + $TotInstrs =~ s/,//g; + }; + + /^==\d+==\s+D\s+refs:\s+[0-9,]+\s+\(([0-9,]+)\s+rd\s+\+\s+([0-9,]+)\s+wr/ && do { + $TotReads = $1; + $TotWrites = $2; + $TotReads =~ s/,//g; + $TotWrites =~ s/,//g; + }; + + /^==\d+==\s+L2d\s+misses:\s+([0-9,]+)/ && do { + $TotMisses = $1; + $TotMisses =~ s/,//g; + }; + } + close(STATS); } +