use strict; use warnings; my $DEBUG = (shift @ARGV || 0); my $version = 100; # pre-Oracle9i input data is centi-seconds. my %cid; # cursor id of recursive cursors. my %ela; # $ela{event} contains sum of ela statistics for event my %ctr; # $ctr{event} contains count of events my $sum_ela = 0; # sum of all ela times across events my $r = 0; # response time for database call my $action = "(?:PARSE|EXEC|FETCH|UNMAP|SORT UNMAP)"; while (<>) { if (/^(Oracle9i)/) { $version = 1000000; # Oracle9i input data is micro-seconds. print "version $1 trace data found\n" if $DEBUG; } if (/^PARSING IN CURSOR #(\d+) len=(\d+) dep=(\d+)/i) { $cid{$1} = $3; print "Cursor #$1 is recursive level $cid{$1}\n" if $DEBUG; } if (/^WAIT #(\d+): nam='([^']*)' ela=\s*(\d+)/i) { if (!defined $cid{$1} || $cid{$1} == 0) { # check dep= value for complete trace input only $ctr{$2}++; $ela{$2} += $3; $sum_ela += $3; } } elsif (/^$action #(\d+):c=(\d+),e=(\d+),p=(\d+),cr=(\d+),cu=(\d+),mis=(\d+),r=(\d+),dep=(\d+)/i) { if (!defined $cid{$1} || $cid{$1} == 0) { # check dep= value for complete trace input only $ctr{"CPU service"}++; $ela{"CPU service"} += $2; $r += $3; } } } $ela{"unaccounted-for"} = $r - ($ela{"CPU service"} + $sum_ela); $ctr{"unaccounted-for"} = 0; printf "\n%-30s %16s %10s %10s\n", "Response Time Component", "Duration", "# Calls", "Dur/Call"; printf "%30s- %16s %10s %10s\n", "-"x30, "-"x16, "-"x10, "-"x10; printf "%-30s %8.2fs %5.1f%% %10d %8.7f\n", $_, $ela{$_}/$version, $ela{$_}/$r*100, $ctr{$_}, ($ctr{$_} && $ela{$_}/$ctr{$_}/$version ||0) for sort { $ela{$b} <=> $ela{$a} } keys %ela; printf "%30s- %16s %10s %10s\n", "-"x30, "-"x16, "-"x10, "-"x10; printf "%-30s %8.2fs %5.1f%%\n\n", "Total response time", $r/$version, 100;