Changeset 81dea5b


Ignore:
Timestamp:
05/28/15 18:09:28 (9 years ago)
Author:
Hal Finkel <hfinkel@…>
Branches:
master
Children:
6bfe6a1
Parents:
6520ef5
git-author:
Hal Finkel <hfinkel@…> (05/28/15 18:09:28)
git-committer:
Hal Finkel <hfinkel@…> (05/28/15 18:09:28)
Message:

do the whole pdf conversion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • memlog2dot

    r6520ef5 r81dea5b  
    33use File::Basename; 
    44 
     5my $memlog_fn = $ARGV[0]; 
     6my $out_dir = $ARGV[1] || '.'; 
     7 
     8if (! -f $memlog_fn) { 
     9  print "Usage: $0 <memlog file> [<output directory>]\n"; 
     10  exit 1; 
     11} 
     12 
     13open(MEMLOG, $memlog_fn) || die "Can't open $memlog_fn: $!"; 
     14 
    515my $total_size = 0; 
    616my %roots; 
    717my %all_nodes; 
    8 foreach my $line ( <STDIN> ) { 
     18foreach my $line (<MEMLOG>) { 
    919  chomp($line); 
    1020  my @parts = split(/\t/, $line); 
     
    7686} 
    7787 
     88close(MEMLOG); 
     89 
     90my $dot_fn = "$out_dir/" . basename($memlog_fn) . ".dot"; 
     91my $ps_fn = "$out_dir/" . basename($memlog_fn) . ".ps"; 
     92my $pdf_fn = "$out_dir/" . basename($memlog_fn) . ".pdf"; 
     93 
     94open(DOT, ">$dot_fn") || die "Can't open $dot_fn: $!"; 
     95 
    7896sub format_bytes($) { 
    7997  my @sizes = qw( B KB MB GB TB PB ); 
     
    89107} 
    90108 
    91 printf("digraph \"memlog %s\" {\n", format_bytes($total_size)); 
    92 print("size=\"8,11\";\n"); 
    93 print("node [width=0.375,height=0.25];\n"); 
     109printf DOT ("digraph \"memlog %s\" {\n", format_bytes($total_size)); 
     110print DOT ("size=\"8,11\";\n"); 
     111print DOT ("node [width=0.375,height=0.25];\n"); 
    94112 
    95113my %cached_names; 
     
    161179  } 
    162180 
    163   printf("N%s [label=\"%s\\n%s\", shape=box, fontsize=%.1f%s];\n", 
     181  printf DOT ("N%s [label=\"%s\\n%s\", shape=box, fontsize=%.1f%s];\n", 
    164182    $pc, $name, format_bytes($local_size), $fs); 
    165183} 
     
    186204    my $fs = 40.0 * $frac**0.125; 
    187205 
    188     printf("N%s -> N%s [label=\"%s\", weight=%d, style=\"%s\", fontsize=%.1f];\n", 
     206    printf DOT ("N%s -> N%s [label=\"%s\", weight=%d, style=\"%s\", fontsize=%.1f];\n", 
    189207      $pc, $cpc, format_bytes($child_size), $weight, $style, $fs); 
    190208  } 
    191209} 
    192210 
    193 print("}\n"); 
    194  
     211print DOT ("}\n"); 
     212 
     213close(DOT); 
     214 
     215system("dot -Tps2 < '$dot_fn' > '$ps_fn'"); 
     216system("ps2pdf '$ps_fn' '$pdf_fn'"); 
     217 
     218exit 0; 
     219 
Note: See TracChangeset for help on using the changeset viewer.