#!/usr/bin/perl -w # 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/.
sub usage() {
print <<EOUSAGE; # bloatdiff.pl - munges the output from # XPCOM_MEM_BLOAT_LOG=1 # firefox -P default resource:///res/bloatcycle.html # so that it does some summary and stats stuff. # # To show leak test results for a set of changes, do something like this: # # XPCOM_MEM_BLOAT_LOG=1 # firefox -P default resource:///res/bloatcycle.html > a.out # **make change** # firefox -P default resource:///res/bloatcycle.html > b.out # bloatdiff.pl a.out b.out
if (!$OLDFILE or
! -e $OLDFILE or
-z $OLDFILE) {
print "\nError: Previous log file not specified, does not exist, or is empty.\n\n";
&usage();
exit 1;
}
if (!$NEWFILE or
! -e $NEWFILE or
-z $NEWFILE) {
print "\nError: Current log file not specified, does not exist, or is empty.\n\n";
&usage();
exit 1;
}
sub processFile {
my ($filename, $map, $prevMap) = @_;
open(FH, $filename); while (<FH>) { if (m{
^\s*(\d+)\s # Line number
([\w:]+)\s+ # Name
(-?\d+)\s+ # Size
(-?\d+)\s+ # Leaked
(-?\d+)\s+ # Objects Total
(-?\d+)\s+ # Objects Rem
\(\s*(-?[\d.]+)\s+ # Objects Mean
\+/-\s+
([\w.]+)\)\s+ # Objects StdDev
(-?\d+)\s+ # Reference Total
(-?\d+)\s+ # Reference Rem
\(\s*(-?[\d.]+)\s+ # Reference Mean
\+/-\s+
([\w\.]+)\) # Reference StdDev
}x) {
$$map{$2} = { name => $2,
size => $3,
leaked => $4,
objTotal => $5,
objRem => $6,
objMean => $7,
objStdDev => $8,
refTotal => $9,
refRem => $10,
refMean => $11,
refStdDev => $12,
bloat => $3 * $5 # size * objTotal
};
} else { # print "failed to parse: $_\n";
}
}
close(FH);
}
sub getLeaksDelta {
my ($key) = @_;
my $oldLeaks = $oldMap{$key}{leaked} || 0;
my $newLeaks = $newMap{$key}{leaked};
my $percentLeaks = 0; if ($oldLeaks == 0) { if ($newLeaks != 0) { # there weren't any leaks before, but now there are!
$percentLeaks = $inf;
}
} else {
$percentLeaks = ($newLeaks - $oldLeaks) / $oldLeaks * 100;
} # else we had no record of this class before
return ($newLeaks - $oldLeaks, $percentLeaks);
}
sub getBloatDelta {
my ($key) = @_;
my $newBloat = $newMap{$key}{bloat};
my $percentBloat = 0;
my $oldSize = $oldMap{$key}{size} || 0;
my $oldTotal = $oldMap{$key}{objTotal} || 0;
my $oldBloat = $oldTotal * $oldSize; if ($oldBloat == 0) { if ($newBloat != 0) { # this class wasn't used before, but now it is
$percentBloat = $inf;
}
} else {
$percentBloat = ($newBloat - $oldBloat) / $oldBloat * 100;
} # else we had no record of this class before
return ($newBloat - $oldBloat, $percentBloat);
}
if (! $newMap{"TOTAL"} or
! $newMap{"TOTAL"}{bloat}) { # It's OK if leaked or leakPercent are 0 (in fact, that would be good). # If bloatPercent is zero, it is also OK, because we may have just had # two runs exactly the same or with no new bloat.
print "\nError: unable to calculate bloat/leak data.\n";
print "There is no data present.\n\n";
print "HINT - Did your test run complete successfully?\n";
print "HINT - Are you pointing at the right log files?\n\n";
&usage();
exit 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.