Changeset 81dea5b
- Timestamp:
- 05/28/15 18:09:28 (9 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
memlog2dot
r6520ef5 r81dea5b 3 3 use File::Basename; 4 4 5 my $memlog_fn = $ARGV[0]; 6 my $out_dir = $ARGV[1] || '.'; 7 8 if (! -f $memlog_fn) { 9 print "Usage: $0 <memlog file> [<output directory>]\n"; 10 exit 1; 11 } 12 13 open(MEMLOG, $memlog_fn) || die "Can't open $memlog_fn: $!"; 14 5 15 my $total_size = 0; 6 16 my %roots; 7 17 my %all_nodes; 8 foreach my $line ( <STDIN>) {18 foreach my $line (<MEMLOG>) { 9 19 chomp($line); 10 20 my @parts = split(/\t/, $line); … … 76 86 } 77 87 88 close(MEMLOG); 89 90 my $dot_fn = "$out_dir/" . basename($memlog_fn) . ".dot"; 91 my $ps_fn = "$out_dir/" . basename($memlog_fn) . ".ps"; 92 my $pdf_fn = "$out_dir/" . basename($memlog_fn) . ".pdf"; 93 94 open(DOT, ">$dot_fn") || die "Can't open $dot_fn: $!"; 95 78 96 sub format_bytes($) { 79 97 my @sizes = qw( B KB MB GB TB PB ); … … 89 107 } 90 108 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");109 printf DOT ("digraph \"memlog %s\" {\n", format_bytes($total_size)); 110 print DOT ("size=\"8,11\";\n"); 111 print DOT ("node [width=0.375,height=0.25];\n"); 94 112 95 113 my %cached_names; … … 161 179 } 162 180 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", 164 182 $pc, $name, format_bytes($local_size), $fs); 165 183 } … … 186 204 my $fs = 40.0 * $frac**0.125; 187 205 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", 189 207 $pc, $cpc, format_bytes($child_size), $weight, $style, $fs); 190 208 } 191 209 } 192 210 193 print("}\n"); 194 211 print DOT ("}\n"); 212 213 close(DOT); 214 215 system("dot -Tps2 < '$dot_fn' > '$ps_fn'"); 216 system("ps2pdf '$ps_fn' '$pdf_fn'"); 217 218 exit 0; 219
Note: See TracChangeset
for help on using the changeset viewer.