Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 56 lines (49 sloc) 1.857 kB
f49a206 @pmichaud Add analyze-parse, a simple Perl script for summarizing --parsetrace …
pmichaud authored
1 #! perl
2
3 my $laststamp = 0;
4 my @callstack;
5 my @calltime;
6 my %stats;
7
8 while (<>) {
9 my ($eventstamp, $loc, $event, $routine) = split ' ', $_;
10 next unless ($event =~ /START|PROTO|PASS|FAIL/);
11 $routine = '<anon>' if ($routine eq '' || $routine eq 'at');
12 my $elapsed = $eventstamp - $laststamp;
13 $laststamp = $eventstamp;
14 if (@callstack) { $calltime[-1] += $elapsed; }
15 if ($event eq 'START' || $event eq 'PROTO') {
16 $stats{$routine}{'callcount'}++;
17 push @callstack, $routine;
18 push @calltime, 0;
19 next;
20 }
21 if ($callstack[-1] ne $routine) {
22 die "malformed trace: $routine vs @callstack";
23 }
24 else { pop @callstack; }
25 if ($event eq 'PASS') {
26 $stats{$routine}{'passcount'}++;
27 $stats{$routine}{'passtime'} += pop @calltime;
28 }
29 if ($event eq 'FAIL') {
30 $stats{$routine}{'failcount'}++;
31 $stats{$routine}{'failtime'} += pop @calltime;
32 }
33 }
34
35 foreach my $r (keys %stats) {
36 $stats{$r}{'calltime'} = $stats{$r}{'passtime'} + $stats{$r}{'failtime'};
37 foreach (qw( callcount calltime passcount passtime failcount failtime )) {
38 $stats{'TOTAL'}{$_} += $stats{$r}{$_};
39 }
40 }
41
42 my @keys = sort { $stats{$b}{'calltime'} <=> $stats{$a}{'calltime'} }
43 keys %stats;
44
45 print " All Passing Failing \n";
46 print "Regex Calls Time Calls Time Calls Time \n";
47 print "--------------------------------------------------------------------------------------\n";
48
49 foreach my $r (@keys) {
50 printf "%-40s: %5d %8.4f %5d %8.4f %5d %8.4f\n",
51 $r,
52 $stats{$r}{'callcount'}, $stats{$r}{'calltime'},
53 $stats{$r}{'passcount'}, $stats{$r}{'passtime'},
54 $stats{$r}{'failcount'}, $stats{$r}{'failtime'};
55 }
Something went wrong with that request. Please try again.