tools/trace-malloc/merge.pl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #!/usr/bin/perl
     2 # This Source Code Form is subject to the terms of the Mozilla Public
     3 # License, v. 2.0. If a copy of the MPL was not distributed with this
     4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     7 $argv = $ARGV[0];
     8 open( bloatFile, $argv ) or die "Can't open $argv: $!\n";
     9 while (<bloatFile>) {
    10     if (/name=/) {
    11         ($td,$name,$func,$a,$ntd) = split(/>/, $_);
    12         ($fname, $memSize) = split( /&nbsp;/, $func );
    13         ($trash, $linkName) = split( /"/, $name );
    14         $namesLinks{$fname} = $linkName;
    15         if ($namesSizes{$fname}) {
    16             $namesSizes{$fname} = $namesSizes{$fname} + $memSize;
    17         }
    18         else {
    19             $namesSizes{$fname} = $memSize;
    20         }
    21     }
    22 }
    24 $argv = $ARGV[1];
    25 if ($argv)
    26 {
    27     open( bloatFile, $argv ) or die "Can't open $argv: $!\n";
    28     while (<bloatFile>) {
    29         if (/name=/) {
    30             ($td,$name,$func,$a,$ntd) = split(/>/, $_);
    31             ($fname, $memSize) = split( /&nbsp;/, $func );
    32             $namesSizes{$fname} = $namesSizes{$fname} - $memSize;
    33         }
    34     }
    35 }
    37 sub byvalue { $namesSizes{$b} <=> $namesSizes{$a} }
    40 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">';
    41 print "\n<html><head>\n";
    42 print "<title>Bloat Blame Delta</title>\n";
    43 print '<link rel="stylesheet" type="text/css" href="blame.css">';
    44 print "\n</head>\n<body>\n<table>\n";
    45 print "<thead><tr><td>Memory Allocated</td><td>Function Name</td><td>Link</td></tr></thead>\n";
    47 foreach $key (sort byvalue keys %namesSizes) {
    48     if ($namesSizes{$key}) 
    49     {
    50         print "<tr>\n";
    51         print '  <td>', $namesSizes{$key},"</td>\n"; 
    52         print "  <td> <a href=\"$ARGV[0]#$namesLinks{$key}\">", $key,  "</a></td>\n";
    53         print "</tr>\n"
    54     }
    55 }
    57 print "</table>\n</body></html>";

mercurial