OLD | NEW |
| (Empty) |
1 #!/usr/bin/perl | |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 sub process_raw($$) { | |
7 my $file = shift; | |
8 my $search = shift; | |
9 | |
10 my %leaks = (); | |
11 | |
12 my $save = 0; | |
13 my $print = 0; | |
14 my $bytes = 0; | |
15 my $calls = 0; | |
16 my $sum_bytes = 0; | |
17 my $sum_calls = 0; | |
18 | |
19 open (LOGFILE, "$file") or die("could not open $file"); | |
20 while(<LOGFILE>) { | |
21 my $line = $_; | |
22 if ($line =~ m/([0-9]*) bytes, ([0-9]*) allocs/) { | |
23 $save = ""; | |
24 $print = 0; | |
25 $bytes = $1; | |
26 $calls = $2; | |
27 } | |
28 elsif ($line =~ m/$search/) { | |
29 $print = 1; | |
30 } | |
31 elsif ($line =~ m/=============/) { | |
32 $save .= $line; | |
33 if ($print) { | |
34 print "$bytes bytes ($calls calls)\n"; | |
35 print $save; | |
36 $sum_bytes += $bytes; | |
37 $sum_calls += $calls; | |
38 $save = ""; | |
39 $print = 0; | |
40 $calls = 0; | |
41 } | |
42 } | |
43 $save .= $line; | |
44 } | |
45 print("TOTAL: $sum_bytes bytes ($sum_calls calls)\n"); | |
46 } | |
47 | |
48 | |
49 # ----- Main ------------------------------------------------ | |
50 | |
51 # Get the command line argument | |
52 my $filename = shift; | |
53 my $search = shift; | |
54 | |
55 # Process the file. | |
56 process_raw($filename, $search); | |
OLD | NEW |