#!/bin/bash

###########################################################
#        name: worsttime.sh
#     version: 0.0
# description: Finds the worst e times (time elapsed for a
#              system call) and ela times (time elapsed
#              for a wait event) in an event 10046 trace
#              file.
#    synopsis: Takes two arguments. 
#              $1 is the trace file name.
#              $2 is the number of lines to report.
#    comments: Oracle 7 and 8 report these times in 
#              centiseconds, but 9 and higher report them
#              in microseconds.
#  created by: D. Clement
#        date: 12-AUG-2004
# modified by: 
#        date:
###########################################################
for e in $(fgrep ',e=' $1|cut -d ',' -f 2|cut -d '=' -f 2|sort -nu|tail -$2)
do
  fgrep ',e='$e $1
done
for e in $(fgrep ' ela= ' $1|cut -d '=' -f 3|cut -d ' ' -f 2|sort -nu|tail -$2) 
do
  fgrep ' ela= '$e $1
done