Changeset 20b45de


Ignore:
Timestamp:
05/29/15 19:05:23 (9 years ago)
Author:
Hal Finkel <hfinkel@…>
Branches:
master
Children:
24aa734
Parents:
510af01
git-author:
Hal Finkel <hfinkel@…> (05/29/15 19:05:23)
git-committer:
Hal Finkel <hfinkel@…> (05/29/15 19:05:23)
Message:

add a txt output too for analysis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • memlog2dot

    r1bd82e0 r20b45de  
    147147} 
    148148 
     149my $txt_fn = "$out_dir/" . basename($memlog_fn) . ".txt"; 
    149150my $dot_fn = "$out_dir/" . basename($memlog_fn) . ".dot"; 
    150151my $ps_fn = "$out_dir/" . basename($memlog_fn) . ".ps"; 
    151152my $pdf_fn = "$out_dir/" . basename($memlog_fn) . ".pdf"; 
    152153 
     154open(TXT, ">$txt_fn") || die "Can't open $txt_fn: $!"; 
    153155open(DOT, ">$dot_fn") || die "Can't open $dot_fn: $!"; 
    154156 
     
    172174printf DOT ("Legend [shape=box, fontsize=100, shape=oval," . 
    173175            "label=\"Total: %s active at maxrss = %s after %s s\"];\n", 
     176            format_bytes($total_size), format_bytes($max_rss), $max_rss_time); 
     177 
     178printf TXT ("memlog: Total: %s active at maxrss = %s after %s s\n\n", 
    174179            format_bytes($total_size), format_bytes($max_rss), $max_rss_time); 
    175180 
     
    247252foreach my $pc (keys %all_nodes) { 
    248253  my $node = $all_nodes{$pc}; 
    249   my $name = get_name($node); 
    250254 
    251255  my $local_size = $node->{'size'}; 
     
    260264  } 
    261265 
     266  my $name = get_name($node); 
     267 
    262268  printf DOT ("N%s [label=\"%s\\n%s\", shape=box, fontsize=%.1f%s];\n", 
    263269    $pc, $name, format_bytes($local_size), $fs); 
     
    265271 
    266272foreach my $pc (keys %all_nodes) { 
     273  if ($skipped{$pc}) { 
     274    next; 
     275  } 
     276 
    267277  my $node = $all_nodes{$pc}; 
    268  
    269278  my $local_size = $node->{'size'}; 
    270   if ($skipped{$pc}) { 
    271     next; 
    272   } 
    273279 
    274280  foreach my $cpc (keys %{$node->{'child_sizes'}}) { 
     
    292298print DOT ("}\n"); 
    293299 
     300foreach my $pc (sort { $all_nodes{$::b}->{'size'} <=> 
     301                       $all_nodes{$::a}->{'size'} } keys %all_nodes) { 
     302  if ($skipped{$pc}) { 
     303    next; 
     304  } 
     305 
     306  print TXT ('*' x 80) . "\n\n"; 
     307 
     308  my $node = $all_nodes{$pc}; 
     309 
     310  my $local_size = $node->{'size'}; 
     311  printf TXT ("%s - %.1f%%\n", format_bytes($local_size), 
     312              $local_size * 100.0 / $total_size); 
     313 
     314  my $name = get_name($node); 
     315  $name =~ s/\\n/\n/g; 
     316 
     317  print TXT "$name\n$pc\n"; 
     318 
     319  print TXT "\nMEMORY ALLOCATED BY CALLEES:\n"; 
     320 
     321  foreach my $cpc (sort { $node->{'child_sizes'}->{$::b} <=> 
     322                          $node->{'child_sizes'}->{$::a} } 
     323                     keys %{$node->{'child_sizes'}}) { 
     324    if ($skipped{$cpc}) { 
     325      next; 
     326    } 
     327 
     328    my $child_node = $all_nodes{$cpc}; 
     329    my $child_size = $node->{'child_sizes'}->{$cpc}; 
     330 
     331    printf TXT ("\t%s - %.1f%%\n", format_bytes($child_size), 
     332                $child_size * 100.0 / $local_size); 
     333 
     334    my $child_name = get_name($child_node); 
     335    $child_name =~ s/\\n/\n\t/g; 
     336    print TXT "\t$child_name\n\t$cpc\n"; 
     337 
     338    print TXT "\n"; 
     339  } 
     340 
     341  print TXT "\n"; 
     342} 
     343 
     344close(TXT); 
    294345close(DOT); 
    295346 
Note: See TracChangeset for help on using the changeset viewer.