[padb] r442 committed - In tree mode add the option to truncate the "rankspec" list of stack f...

padb at googlecode.com padb at googlecode.com
Thu Jun 23 00:18:54 BST 2011


Revision: 442
Author:   apittman at gmail.com
Date:     Wed Jun 22 16:17:55 2011
Log:      In tree mode add the option to truncate the "rankspec" list of  
stack frames.
This causes padb to display less information but avoids the problem on  
large jobs
where the list of ranks can be several lines long at times.
Truncate the rankspec to be 'N' entries long where each entry is a comma
seperated part, that is '1' or '12-17' would be example entries.  Limit the
number of entries by only showing the first ones in the list and adding
ellipses if not all are shown.
This is going to need to be made tunable and a sensible default chosen.

http://code.google.com/p/padb/source/detail?r=442

Modified:
  /trunk/src/padb

=======================================
--- /trunk/src/padb	Sat Jun 18 16:24:16 2011
+++ /trunk/src/padb	Wed Jun 22 16:17:55 2011
@@ -4285,8 +4285,10 @@
          my @values = keys %{ $d->{target_data}{$key} };

          if ( @values == 1 ) {
-            my $line = "  $vref->{type_name} = '$values[0]' "
-              . rng_convert_to_user( $d->{target_data}{$key}{ $values[0] }  
);
+            my $line =
+              "  $vref->{type_name} = '$values[0]' "
+              . rng_convert_to_user_truncate(
+                $d->{target_data}{$key}{ $values[0] } );
              push @{ $tree->{$peer}->{aux} }, $line;
          } elsif ( @values > $max_show ) {
              my $line = "  $vref->{type_name}: "
@@ -4295,8 +4297,10 @@
          } else {
              push @{ $tree->{$peer}->{aux} }, "  $vref->{type_name}:";
              foreach my $value ( sort @values ) {
-                my $line = "      '$value' "
-                  . rng_convert_to_user( $d->{target_data}{$key}{$value} );
+                my $line =
+                  "      '$value' "
+                  . rng_convert_to_user_truncate(
+                    $d->{target_data}{$key}{$value} );
                  push @{ $tree->{$peer}->{aux} }, $line;

              }
@@ -4389,7 +4393,7 @@
      my $child_enforce_spec = 0;
      foreach my $peer (@peers) {

-        my $vpspec = rng_convert_to_user( $tree->{$peer}->{range} );
+        my $vpspec = rng_convert_to_user_truncate( $tree->{$peer}->{range}  
);
          if ( @peers != 1 or $parent ne $vpspec or $enforce_spec ) {
              $ret .= "$indent-----------------\n";
              my $count = $tree->{$peer}->{count};
@@ -5214,6 +5218,19 @@
        map { $_->{l} == $_->{u} ? $_->{l} : $_->{l} . q{-} . $_->{u} }  
@{$rg};
      return "[$range]";
  }
+
+sub rng_convert_to_user_truncate {
+    my ($rg) = @_;
+
+    my $max_rankspec_length = 5;
+    my @spec =
+      map { $_->{l} == $_->{u} ? $_->{l} : $_->{l} . q{-} . $_->{u} }  
@{$rg};
+    if ( $#spec >= $max_rankspec_length ) {
+        return sprintf( "[%s...]",
+            join q{,}, @spec[ 0 .. $max_rankspec_length - 1 ] );
+    }
+    return sprintf( "[%s]", join q{,}, @spec );
+}

  sub rng_shift {
      my ($rg) = @_;




More information about the padb-devel mailing list