3 # Copyright 2017 Intel Corporation.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Script for graphical representation of VSPERF results
20 # ./create_graph ["test names" [filter [directory]]]
23 # "test names" is a !!! quoted !!! string with vsperf testcase names separated
25 # Default value: "phy2phy_tput"
27 # "filter" is used to select matching VSPERF results; Its value
28 # will be used as PATTERN of grep command executed on selected
30 # Default value: ",OvsDpdkVhost,"
32 # "directory" is a directory name, where vsperf results (i.e. results_*
33 # subdirectories) are located
34 # Default value: "/tmp"
36 # Example of invocation:
37 # ./create_graph "phy2phy_tput phy2phy_cont pvp_cont pvvp_cont" ",OvsVanilla,"
39 TESTS="phy2phy_tput" # default set of TCs to be plotted
40 FILTER=",OvsDpdkVhost," # default filter to be applied on matching CSV files
41 NUMBER_OF_RESULTS=50 # max number of recent results to be compared in graph
42 CSV_RESULT_COL=2 # column number with result to be plotted, e.g. 2 for rx_throughput_fps
43 B2B_CSV_RESULT_COL=1 # column number with result to be plotted for back2back TCs
44 CSV_PKT_SIZE_COL=12 # column number with frame/packet size
45 B2B_CSV_PKT_SIZE_COL=4 # column number with frame/packet size for back2back TCs
46 NUMBER_OF_PKT_SIZES=0 # to be detected automatically
47 MAX_NUMBER_OF_PKT_SIZES=10
48 DIR="/tmp" # directory where vsperf results are stored
50 TYPE="TPUT" # customization of graph for TPUT or B2B
52 function clean_data() {
58 function prepare_data() {
59 for test_name in $TESTS; do
61 CSV_LIST=`grep -r ",${test_name}," ${DIR}/results_*/*csv | grep $FILTER | cut -d':' -f1 | uniq | sort | tail -n ${NUMBER_OF_RESULTS}`
62 for result_file in $CSV_LIST ; do
63 tmp_dir=`dirname $result_file`
64 TIMESTAMP=`basename $tmp_dir | cut -d'_' -f2-`
65 if [ $FIRST -eq 1 ] ; then
66 NUMBER_OF_PKT_SIZES=$((`wc -l ${result_file} | cut -d' ' -f1`-1))
67 if [ $NUMBER_OF_PKT_SIZES -gt $MAX_NUMBER_OF_PKT_SIZES ] ; then
68 NUMBER_OF_PKT_SIZES=$MAX_NUMBER_OF_PKT_SIZES
70 if grep back2back ${result_file} &> /dev/null ; then
71 PKT_SIZE_COL=$B2B_CSV_PKT_SIZE_COL
72 RES_COL=$B2B_CSV_RESULT_COL
75 PKT_SIZE_COL=$CSV_PKT_SIZE_COL
76 RES_COL=$CSV_RESULT_COL
79 RESULT_HEADER=`tail -n+2 ${result_file} | head -n ${NUMBER_OF_PKT_SIZES} | cut -d',' -f${PKT_SIZE_COL} | paste -d',' -s`
80 echo "[$TYPE] Date/PKT Size [B],${RESULT_HEADER}" > "${test_name}.csv"
83 RESULT_4ALL_PKT_SIZES=`tail -n+2 ${result_file} | head -n ${NUMBER_OF_PKT_SIZES} | cut -d',' -f${RES_COL} | paste -d',' -s`
84 echo "${TIMESTAMP},${RESULT_4ALL_PKT_SIZES}" >> "${test_name}.csv"
89 function plot_data() {
90 echo "Created graphs:"
91 SUFFIX=`echo $FILTER | tr -d -C [:alnum:]`
92 for TEST_CSV in *csv; do
93 [ ! -f $TEST_CSV ] && continue
94 TEST_NAME=`basename ${TEST_CSV} .csv`"_${SUFFIX}"
95 OUTPUT="$TEST_NAME.plot"
97 set datafile separator ","
99 set timefmt "%Y-%m-%d_%H:%M:%S"
103 set term png size 1024,768
106 if grep '^\[B2B\]' ${TEST_CSV} &> /dev/null ; then
107 echo 'set ylabel "frames"' >> $OUTPUT
108 echo 'set log y' >> $OUTPUT
109 echo 'set yrange [1:]' >> $OUTPUT
111 echo 'set ylabel "fps"' >> $OUTPUT
112 echo 'set yrange [0:]' >> $OUTPUT
116 echo "set title \"$TEST_NAME\"" >> $OUTPUT
117 echo "set output \"${PNG_PREFIX}${TEST_NAME}.png\"" >> $OUTPUT
118 echo -n "plot " >> $OUTPUT
120 while [ $iter -lt $NUMBER_OF_PKT_SIZES ] ; do
122 echo $"$SEP '$TEST_CSV' using 1:$COL with linespoints title columnheader($COL) \\" >> $OUTPUT
126 echo -e "\t${PNG_PREFIX}${TEST_NAME}.png"
135 # override default set of TESTS if specified by 1st parameter
136 if [ "$1" != "" ] ; then
140 # override default filter if specified by 2nd parameter
141 if [ "$2" != "" ] ; then
145 # override default directory with results by 3rd parameter
146 if [ "$3" != "" ] ; then
151 echo -e "Plot data input:"
152 echo -e "\tTESTS: $TESTS"
153 echo -e "\tFilter: $FILTER"
154 echo -e "\tResults direcotry: $DIR"