From e95f03bd55aff94f939933dfd1a396b01d3c7ffd Mon Sep 17 00:00:00 2001 From: "slamm%netscape.com" Date: Sat, 23 Oct 1999 01:22:41 +0000 Subject: [PATCH] Parse build logs for bloat data from warren@netscape.com's bloat tool. git-svn-id: svn://10.0.0.236/trunk@51614 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/tinderbox/bloat.pl | 85 +++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 mozilla/webtools/tinderbox/bloat.pl diff --git a/mozilla/webtools/tinderbox/bloat.pl b/mozilla/webtools/tinderbox/bloat.pl new file mode 100755 index 00000000000..a686c6d1b6b --- /dev/null +++ b/mozilla/webtools/tinderbox/bloat.pl @@ -0,0 +1,85 @@ +#! /usr/bonsaitools/bin/perl +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# The contents of this file are subject to the Mozilla Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations +# under the License. +# +# The Original Code is Tinderbox +# +# The Initial Developer of the Original Code is Netscape Communications +# Corporation. Portions created by Netscape are Copyright (C) 1999 +# Netscape Communications Corporation. All Rights Reserved. +# +# Contributor(s): Stephen Lamm + +# +# bloat.pl - Process bloat data from warren@netscape.com's bloat tool. +# Write data to $tree/bloat.dat in the following format, +# +# |<% leaks increase>|<% bloat increase> +# + +sub usage { + warn "./bloat.pl "; +} + +use FileHandle; + +unless ($#ARGV == 1) { + &usage; + die "Error: Wrong number of arguments\n"; +} + +($tree, $logfile) = @ARGV; + +die "Error: No tree named $tree" unless -r "$tree/treedata.pl"; +require "$tree/treedata.pl"; + +# Seach the build log for the bloat data +# +$fh = new FileHandle "gunzip -c $tree/$logfile |" + or die "Unable to open $tree/$logfile\n"; +($leaks, $bloat) = find_bloat_data($fh); +$fh->close; + +unless (defined $leaks and defined $bloat) { + die "No bloat data found in log.\n"; +} + +# Save the bloat data to 'bloat.dat' +# +open BLOAT, ">>$tree/bloat.dat" or die "Unable to open $tree/bloat.dat"; +print BLOAT "$logfile|$leaks|$bloat\n"; +close BLOAT; + + +# end of main +#============================================================ + +sub find_bloat_data { + my ($fh) = $_[0]; + local $_; + my $inBloatStats = 0; + + while (<$fh>) { + if ($inBloatStats) { + if (/^TOTAL/) { + chomp; + my ($leaks, $bloat) = (split)[2,4]; + chop $leaks; + chop $bloat; + return $leaks, $bloat; + } + } else { + $inBloatStats = 1 if /^\#* BLOAT STATISTICS/; + } + } + return undef, undef; +}