DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (5b81998bb7ab)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#!/usr/bin/perl
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


$argv = $ARGV[0];
open( bloatFile, $argv ) or die "Can't open $argv: $!\n";
while (<bloatFile>) {
    if (/name=/) {
        ($td,$name,$func,$a,$ntd) = split(/>/, $_);
        ($fname, $memSize) = split( /&nbsp;/, $func );
        ($trash, $linkName) = split( /"/, $name );
        $namesLinks{$fname} = $linkName;
        if ($namesSizes{$fname}) {
            $namesSizes{$fname} = $namesSizes{$fname} + $memSize;
        }
        else {
            $namesSizes{$fname} = $memSize;
        }
    }
}

$argv = $ARGV[1];
if ($argv)
{
    open( bloatFile, $argv ) or die "Can't open $argv: $!\n";
    while (<bloatFile>) {
        if (/name=/) {
            ($td,$name,$func,$a,$ntd) = split(/>/, $_);
            ($fname, $memSize) = split( /&nbsp;/, $func );
            $namesSizes{$fname} = $namesSizes{$fname} - $memSize;
        }
    }
}

sub byvalue { $namesSizes{$b} <=> $namesSizes{$a} }


print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">';
print "\n<html><head>\n";
print "<title>Bloat Blame Delta</title>\n";
print '<link rel="stylesheet" type="text/css" href="blame.css">';
print "\n</head>\n<body>\n<table>\n";
print "<thead><tr><td>Memory Allocated</td><td>Function Name</td><td>Link</td></tr></thead>\n";

foreach $key (sort byvalue keys %namesSizes) {
    if ($namesSizes{$key}) 
    {
        print "<tr>\n";
        print '  <td>', $namesSizes{$key},"</td>\n"; 
        print "  <td> <a href=\"$ARGV[0]#$namesLinks{$key}\">", $key,  "</a></td>\n";
        print "</tr>\n"
    }
}

print "</table>\n</body></html>";