blob: 4962fa3e41b7e5ae42b23cc65fd1f4de0649cecf (
plain)
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
|
#!/usr/bin/perl
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
sub process_raw($$) {
my $file = shift;
my $search = shift;
my %leaks = ();
my $save = 0;
my $print = 0;
my $bytes = 0;
my $calls = 0;
my $sum_bytes = 0;
my $sum_calls = 0;
open (LOGFILE, "$file") or die("could not open $file");
while(<LOGFILE>) {
my $line = $_;
if ($line =~ m/([0-9]*) bytes, ([0-9]*) items/) {
$save = "";
$print = 0;
$bytes = $1;
$calls = $2;
}
elsif ($line =~ m/$search/) {
$print = 1;
}
elsif ($line =~ m/=============/) {
$save .= $line;
if ($print) {
print "$bytes bytes ($calls calls)\n";
print $save;
$sum_bytes += $bytes;
$sum_calls += $calls;
$save = "";
$print = 0;
$calls = 0;
}
}
$save .= $line;
}
print("TOTAL: $sum_bytes bytes ($sum_calls calls)\n");
}
# ----- Main ------------------------------------------------
# Get the command line argument
my $filename = shift;
my $search = shift;
# Process the file.
process_raw($filename, $search);
|