Thu Dec 21 12:57:09 CET 2006 Alexey Rodriguez <mrchebas@gmail.com>
* Extension of testing script to parse PAPI results from GHC programs.
diff -rN -u old-ghc/utils/runstdtest/runstdtest.prl new-ghc/utils/runstdtest/runstdtest.prl
|
old
|
new
|
|
| 72 | 72 | $StatsFile = "$TmpPrefix/stats$$"; |
| 73 | 73 | $CachegrindStats = "cachegrind.out.summary"; |
| 74 | 74 | $SysSpecificTiming = ''; |
| | 75 | $SysCPUCounting = 0; # Use CPU counters |
| 75 | 76 | $Cachegrind = 'no'; |
| | 77 | $Counters = ""; |
| 76 | 78 | |
| 77 | 79 | die "$Pgm: program to run not given as first argument\n" if $#ARGV < 0; |
| 78 | 80 | $ToRun = $ARGV[0]; shift(@ARGV); |
| … |
… |
|
| 118 | 120 | next arg; }; |
| 119 | 121 | /^-(ghc|hbc)-timing$/ && do { $SysSpecificTiming = $1; |
| 120 | 122 | next arg; }; |
| | 123 | /^-cpu-counting-(.)$/ && do { $SysCPUCounting = "$1"; |
| | 124 | next arg; }; |
| 121 | 125 | /^-cachegrind$/ && do { $SysSpecificTiming = 'ghc-instrs'; |
| 122 | 126 | $Cachegrind = 'yes'; |
| 123 | 127 | next arg }; |
| … |
… |
|
| 166 | 170 | # deal with system-specific timing options |
| 167 | 171 | $TimingMagic = ''; |
| 168 | 172 | if ( $SysSpecificTiming =~ /^ghc/ ) { |
| 169 | | $TimingMagic = "+RTS -S$StatsFile -RTS" |
| | 173 | if ($SysCPUCounting) { |
| | 174 | # Count specified CPU events |
| | 175 | $cpu_counting_ghc = "-a$SysCPUCounting"; |
| | 176 | } else { |
| | 177 | $cpu_counting_ghc = ""; |
| | 178 | } |
| | 179 | $TimingMagic = "+RTS -S$StatsFile $cpu_counting_ghc -RTS" |
| 170 | 180 | } elsif ( $SysSpecificTiming eq 'hbc' ) { |
| 171 | 181 | $TimingMagic = "-S$StatsFile"; |
| 172 | 182 | } |
| … |
… |
|
| 300 | 310 | # print out what we found |
| 301 | 311 | print STDERR "<<$SysSpecificTiming: "; |
| 302 | 312 | if ( $Cachegrind ne 'yes') { |
| 303 | | 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)"; |
| | 313 | 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)$Counters"; |
| 304 | 314 | } else { |
| 305 | 315 | 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"; |
| 306 | 316 | }; |
| … |
… |
|
| 359 | 369 | local($max_live) = 0; |
| 360 | 370 | local($tot_live) = 0; # for calculating residency stuff |
| 361 | 371 | local($tot_samples) = 0; |
| | 372 | local($into_gc_counters) = 0; # once we reach into the GC counters part |
| | 373 | local($counters) = ""; |
| | 374 | local($counter) = ""; |
| | 375 | local($count) = 0; |
| 362 | 376 | |
| 363 | 377 | $GCWork = 0; |
| 364 | 378 | while (<STATS>) { |
| … |
… |
|
| 393 | 407 | } elsif ( /^\s*GC\s+time\s*(-*\d+\.\d\d)s\s*\(\s*(-*\d+\.\d\d)s elapsed\)/ ) { |
| 394 | 408 | $GcTime = $1; $GcElapsed = $2; |
| 395 | 409 | } |
| | 410 | |
| | 411 | if ( /CPU GC counters/ ) { |
| | 412 | # Counters that follow correspond to GC |
| | 413 | $into_gc_counters = 1; |
| | 414 | } |
| | 415 | |
| | 416 | if ( /^\s+\(([A-Z_0-9]+)\)\s+:\s+([0-9,]+)/ ) { |
| | 417 | $counter = $1; |
| | 418 | $count = $2; |
| | 419 | $count =~ s/,//g; # Remove commas in numbers |
| | 420 | # Pretty printing elements of a list with type [(String,[Float])] |
| | 421 | # It's a bit lame for passing values but it works. |
| | 422 | if($into_gc_counters) { |
| | 423 | $counters = "$counters(\"GC:$counter\",[$count]),"; |
| | 424 | } else { |
| | 425 | $counters = "$counters(\"$counter\",[$count]),"; |
| | 426 | } |
| | 427 | } |
| | 428 | |
| | 429 | if ( /^\s+\(([A-Z_0-9]+)\)\s+\%\s+of\s+\(([A-Z_0-9]+)\)\s+:\s+([0-9.]+)/ ) { |
| | 430 | $counter = "$1/$2"; # Relative quantity |
| | 431 | $count = $3; |
| | 432 | # Pretty printing elements of a list with type [(String,[Float])] |
| | 433 | # It's a bit lame for passing values but it works. |
| | 434 | if($into_gc_counters) { |
| | 435 | $counters = "$counters(\"GC:$counter\",[$count]),"; |
| | 436 | } else { |
| | 437 | $counters = "$counters(\"$counter\",[$count]),"; |
| | 438 | } |
| | 439 | } |
| | 440 | |
| 396 | 441 | } |
| 397 | 442 | close(STATS) || die "Failed when closing $StatsFile\n"; |
| 398 | 443 | if ( $tot_samples > 0 ) { |
| … |
… |
|
| 401 | 446 | $AvgResidency = int ($tot_live / $tot_samples) ; |
| 402 | 447 | } |
| 403 | 448 | |
| | 449 | if ( length($counters) == 0 ) { |
| | 450 | $Counters = ""; |
| | 451 | } else { |
| | 452 | chop($counters); # remove trailing comma from the last entry |
| | 453 | $Counters = " [$counters]"; |
| | 454 | } |
| | 455 | |
| 404 | 456 | } elsif ( $SysSpecificTiming eq 'hbc' ) { |
| 405 | 457 | |
| 406 | 458 | open(STATS, $StatsFile) || die "Failed when opening $StatsFile\n"; |