Here's a patch that prettifies parrotbench's output.  It also redirects
errors to /dev/null, and replaces them with !!! in the output.  The
benchmarking program is not the correct place to debug errors.

Luke

Index: tools/dev/parrotbench.pl
===================================================================
RCS file: /cvs/public/parrot/tools/dev/parrotbench.pl,v
retrieving revision 1.2
diff -u -r1.2 parrotbench.pl
--- tools/dev/parrotbench.pl    9 Mar 2004 12:03:09 -0000       1.2
+++ tools/dev/parrotbench.pl    9 Mar 2004 13:13:17 -0000
@@ -54,6 +54,8 @@
 my $help        = 0;
 my $list        = 0;
 my $time        = 0;
+my $sep         = "    ";
+my $initialsp   = 0;
 
 GetOptions
   'benchmarks=s'  => \$benchmarks,
@@ -70,7 +72,7 @@
 die "Configuration file \"$conf\" does not exist" unless -e $conf;
 my $file = new IO::File("< $conf")
   or die "Unable to open configuration file \"$conf\"";
-my ( @names, %pathes, %suffixes, @suffixes );
+my ( @names, %pathes, %suffixes, @suffixes, @columns );
 my $i = 0;
 while (<$file>) {
     if (/^\s*(.*):\s*(.*):\s*(.*)$/) {
@@ -98,6 +100,7 @@
             my $benchmark = $1;
             if ( $benchmark =~ /$benchmarks/ ) {
                 $list{$benchmark}++;
+                $initialsp = length $benchmark if length $benchmark > $initialsp;
                 foreach my $name ( @{ $suffixes{$suffix} } ) {
                     $tree{$name}{$suffix}{$benchmark}++;
                 }
@@ -121,36 +124,45 @@
 }
 
 # Benchmark
+$initialsp++;
+print " " x ($initialsp - length $sep);
 foreach my $i ( 0 .. $#names ) {
     foreach my $j ( 0 .. $#{ $suffixes[$i] } ) {
-        print "\t$names[$i]($suffixes[$i][$j])";
+        my $str = "$names[$i]($suffixes[$i][$j])";
+        push @columns, length($str) - 1;
+        print "$sep$str";
     }
 }
 print "\n";
 foreach my $benchmark ( sort keys %list ) {
-    print "$benchmark";
+    printf "%-${initialsp}s", $benchmark;
     my $base = 0;
+    my $count = 0;
     foreach my $i ( 0 .. $#names ) {
         foreach my $j ( 0 .. $#{ $suffixes[$i] } ) {
             if (   $tree{ $names[$i] }{ $suffixes[$i][$j] }{$benchmark}
                 && $pathes{ $names[$i] } )
             {
                 my ( $scuser, $scsys ) = (times)[ 2, 3 ];
-                system "$pathes{$names[$i]} $directory/"
-                  . "$benchmark.$suffixes[$i][$j]"
-                  . '>/dev/null';
+                my $retcode = system "$pathes{$names[$i]} $directory/"
+                                   . "$benchmark.$suffixes[$i][$j]"
+                                   . '>& /dev/null';
+                if ($retcode) {
+                    printf " %$columns[$count++]s$sep", "!!!";
+                    next;
+                }
                 my ( $ecuser, $ecsys ) = (times)[ 2, 3 ];
                 my $used = ( $ecuser - $scuser ) + ( $ecsys - $scsys );
                 $base ||= $used;
                 if ($time) {
-                    printf "\t%.3fs", $used;
+                    printf "%$columns[$count++].3fs$sep", $used;
                 }
                 else {
-                    printf "\t%d%%", $used / ( $base / 100 );
+                    printf "%$columns[$count++]d%%$sep", $used / ( $base / 100 );
                 }
             }
             else {
-                print "\t-";
+                printf " %$columns[$count++]s$sep", '-';
             }
         }
     }

Reply via email to