3 # Parse log files created by innd history profiler
4 # 2001/01/29 - Fabien Tassin
9 my $file = shift || "stathist.log";
10 if ($file eq '-h' || $file eq '--help') {
11 print "Usage: stathist [logfile]\n";
18 my $f = new FileHandle $file;
20 print STDERR "Can't open file: $!\n";
26 while (defined (my $line = <$f>)) {
27 next if $begin && $line !~ / HIS(havearticle|write|setup) begin/;
30 my @c = split /[\[\]\(\) ]+/, $line;
31 ($c[4] eq 'begin') && do {
35 unless (defined $$d{$l}) {
36 $$d{$l}{'min'} = 1E10;
37 $$d{$l}{'total'} = $$d{$l}{'count'} = $$d{$l}{'max'} = 0;
42 ($c[4] eq 'end') && do {
48 $$d{'total'} += $c[5];
49 $$d{'min'} = $c[5] if $$d{'min'} > $c[5];
50 $$d{'max'} = $c[5] if $$d{'max'} < $c[5];
62 unless (defined $inc) {
63 printf "%-16s %10s %14s %10s %10s %10s\n\n", "Function", "Invoked",
64 "Total(s)", "Min(ms)", "Avg(ms)", "Max(ms)";
68 for my $key (sort keys %$data) {
69 next unless $key =~ m/^HIS/;
70 printf "%-16s %10d %14.6f %10.3f %10.3f %10.3f\n", (' ' x $inc) . $key,
71 $$data{$key}{'count'}, $$data{$key}{'total'}, $$data{$key}{'min'} * 1000,
72 $$data{$key}{'total'} / $$data{$key}{'count'} * 1000,
73 $$data{$key}{'max'} * 1000;
74 &report($$data{$key}, $inc + 1)
78 my $data = &parse($file);