2014-09-15 22:00:46 +04:00
|
|
|
#!/bin/bash
|
2014-09-23 16:59:54 +04:00
|
|
|
#
|
|
|
|
# Copyright (c) 2014 Artem Polyakov <artpol84@gmail.com>
|
|
|
|
# $COPYRIGHT$
|
|
|
|
#
|
|
|
|
# Additional copyrights may follow
|
|
|
|
#
|
|
|
|
# $HEADER$
|
2014-09-15 22:00:46 +04:00
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# Evaluate a floating point number expression.
|
|
|
|
|
2014-09-23 16:59:54 +04:00
|
|
|
if [ -z "$1" ] || [ -z "$2" ]; then
|
|
|
|
echo "Need the name of a timing file and the output file"
|
2014-09-15 22:00:46 +04:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2014-12-08 11:52:37 +03:00
|
|
|
initfile=$1
|
2014-09-23 16:59:54 +04:00
|
|
|
postfile=$2
|
2014-12-08 11:52:37 +03:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|