Skip to content

Commit

Permalink
demoperf.sh: Adding script to invoke multiple netperf
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Xu <[email protected]>
  • Loading branch information
xzpeter committed Jul 13, 2016
1 parent 8983b7d commit 8cc1ce6
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions demoperf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Script from Jason Wang to initiate multiple netperf instances.

session=$1
shift 1

if echo $@ | grep -q "\-l [[:digit:]]*"
then
l=`echo $@ | grep -o "\-l [[:digit:]]*" | awk '{print $2}'`
else
l=10
fi

for i in $(seq $session)
do
netperf -D 1 $@ &
done >result 2>debug
sleep $l
pkill netperf

# post processing
# Examine how many sessions were launched
nsession=$(grep MIGRATE result | wc -l)
if [ $nsession -ne $session ]
then
echo the expected sessions could not be met, expect $session get $nsession
echo $@
exit 2
fi

# Track the last netperf instance's start
start=$(less result | grep -n MIGRATE | tail -n 1 | awk -F ':' '{print $1}')

# How many lines of result file
nlines=$(wc -l result | awk '{print $1}')
# We only need from line $start to $end
tail -n $(($nlines-$start)) result > result2

# Track the first netperf instance's end
end=$(less result2 | grep -En "Recv|Local" | head -n 1 | awk -F ':' '{print $1}')
head -n $(($end-1)) result2 > result3

# verify whether we could test with this parallism
nresult=$(wc -l result3 | awk '{print $1}')
if [ $nresult -lt $session ]
then
echo "We couldn't expect this parallism, expect $session get $nresult"
exit 2
fi

# remove the noise from head
niteration=$(($nresult/$session))
tail -n $(($session*$niteration)) result3 > final_result

# calculate the final result
result=0
for this in $(less final_result | awk '{print $3}')
do
result=$(echo $result+$this | bc)
done

result=$(echo "scale=2; $result/$niteration" | bc)
echo $result

0 comments on commit 8cc1ce6

Please sign in to comment.