williamr/scan_epocwind.pl
changeset 2 a600c1a596f7
equal deleted inserted replaced
1:4a4ca5a019bb 2:a600c1a596f7
       
     1 #! perl
       
     2 
       
     3 # Copyright (c) 2009 Symbian Foundation Ltd
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of the License "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Symbian Foundation Ltd - initial contribution.
       
    11 # 
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 # Summarise epocwind.out to identify repetitious and uninteresting comments
       
    16 
       
    17 use strict;
       
    18 
       
    19 my %count_by_word;
       
    20 my %unique_message;
       
    21 
       
    22 my $line;
       
    23 while ($line = <>)
       
    24   {
       
    25   chomp $line;
       
    26   
       
    27   #    494.390	CTouchFeedbackImpl::SetFeedbackArea - Begin
       
    28   my $message = substr($line, 10);  # ignore the timestamp & the tab character
       
    29   if (!defined $unique_message{$message})
       
    30     {
       
    31     $unique_message{$message} = 0;
       
    32     }
       
    33   $unique_message{$message} ++;
       
    34   
       
    35   my ($junk,$count,$word) = split /\s+|:/, $line;
       
    36   $word = $message if (!defined $word);   # no spaces in the line at all
       
    37 
       
    38   if (!defined $count_by_word{$word})
       
    39     {
       
    40     $count_by_word{$word} = 0;
       
    41     }
       
    42   $count_by_word{$word} ++;
       
    43   
       
    44   }
       
    45 
       
    46 my @repeated_lines;
       
    47 foreach my $message (keys %unique_message)
       
    48   {
       
    49   my $count = $unique_message{$message};
       
    50   next if ($count < 10);
       
    51   push @repeated_lines, sprintf "%7d\t%s\n", $count, $message;
       
    52   }
       
    53 
       
    54 print "Repeated lines\n", reverse sort @repeated_lines, "\n";
       
    55 
       
    56 my @repeated_words;
       
    57 foreach my $word (keys %count_by_word)
       
    58   {
       
    59   my $count = $count_by_word{$word};
       
    60   next if ($count < 10);
       
    61   push @repeated_words, sprintf "%7d\t%s\n", $count, $word;
       
    62   }
       
    63 
       
    64 print "Repeated words (rest of the line may vary\n", reverse sort @repeated_words, "\n";
       
    65