1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#!/bin/bash
#
# Copyright (c) 2014 Artem Polyakov <artpol84@gmail.com>
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#####################################################################
# Evaluate a floating point number expression.
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Need the name of a timing file and the output file"
exit 0
fi
initfile=$1
postfile=$2
# 1. Filter OPAL_TRACE entrieas only
# and put the timestamp to the first place
#.2. Sort considering that we dealing with
# floating point numbers
# 3. Return to initial field order and count relative fields
cat $initfile | \
awk 'BEGIN { FPAT = "([^ ]+)|(\"[^\"]+\")" }
{
if( $0 ~ /\[OPAL_TRACE\]/ ){
x = $NF
$NF = $1
$1 = x
print $0
}
}' | sort --general-numeric-sort | \
awk 'BEGIN {
FPAT = "([^ ]+)|(\"[^\"]+\")"
first = 0
prev = 0
}
{
if( first == 0 ){
first = $1
prev = $1
}
x = $1
$1 = $NF
$NF = x
rel_to_first = x - first
rel_to_prev = x - prev
prev = x
print $0, " ", rel_to_prev, " ", rel_to_first
}' > $postfile
|