Home | History | Annotate | Download | only in pthread_create
      1 #! /bin/sh
      2 #
      3 # (C) 2002-2003 Intel Corporation
      4 # Iaky Prez-Gonzlez <inaky.perez-gonzalez (at] intel.com>
      5 #
      6 # Distributed under the FSF's GNU Public License v2 or later.
      7 #
      8 # Plot the output of priority inheritance tests.
      9 
     10 # Modifs by Sebastien Decugis:
     11 # -> plots linespoints instead of dots
     12 # -> legend is outside the graph.
     13 # -> Change axis names and graph title
     14 
     15 FILE=$1
     16 TMP=$(mktemp -d)
     17 
     18 function clean_up
     19 {
     20     rm -rf $TMP
     21 }
     22 
     23 function error
     24 {
     25     cat 1>&2
     26     clean_up
     27     exit 1
     28 }
     29 
     30 trap clean_up EXIT
     31 
     32 if ! cols=$(grep "#[ ]*COLUMNS" $FILE)
     33 then
     34     error <<EOF
     35 E: $FILE: Cannot locate the COLUMNS descriptor
     36 EOF
     37 fi
     38 cols=$(echo $cols | sed 's/#//')
     39 columns=$(echo $cols | awk '{print $2;}')
     40 count=1
     41 while [ $count -le $columns ]
     42 do
     43   column[$count]=$(echo $cols | awk -vcount=$count '{print $(2 + count);}')
     44   if [ -z "${column[$count]}" ]
     45       then
     46       column[$count]=$count;
     47   fi
     48   count=$(($count + 1))
     49 done
     50 
     51 # Set up the plot area
     52 count=2
     53 with="with linespoints"
     54 cat > $TMP/gnuplot.script <<EOF
     55 set term png
     56 set output "scalable.png"
     57 set xlabel "${column[1]}"
     58 set ylabel "Duration (s)"
     59 set key below
     60 set title "pthread_create scalability"
     61 EOF
     62 
     63 # Plot the events
     64 height=15
     65 grep "#[ ]*EVENT" $FILE | sed 's/#//' > $TMP/events
     66 events=$(cat $TMP/events | wc -l)
     67 if [ $events -gt 0 ]
     68 then
     69     step=$(((100 - $height) / $events))
     70     if [ $step -lt 5 ]
     71         then
     72         step=5;
     73     fi
     74     cat $TMP/events | while read event x text
     75       do
     76       if ! [ $event = "EVENT" ]
     77           then
     78           cat 1>&2 <<EOF
     79 E: Unknown event type "$event", ignoring
     80 EOF
     81           continue;
     82       fi
     83       height_text=$(($height + 2))
     84       echo "set arrow from $x, graph 0 to $x, graph 0.$height" >> $TMP/gnuplot.script
     85       echo "set label \"$text\" at $x, graph 0.$height_text center" >> $TMP/gnuplot.script
     86       height=$(($height + $step))
     87     done
     88 fi
     89 
     90 # Plot the data
     91 plot_cmd="plot '$FILE' using 1:2 title \"${column[$count]}\" $with"
     92 count=3
     93 while [ $count -le $columns ]
     94 do
     95 	plot_cmd=$plot_cmd",'$FILE' using 1:$count title \"${column[$count]}\" $with"
     96 	count=$(($count + 1))
     97 done
     98 
     99 echo $plot_cmd >> $TMP/gnuplot.script
    100 
    101 #cp $TMP/gnuplot.script .
    102 ( cat $TMP/gnuplot.script; cat ) | gnuplot
    103 rm -rf $TMP
    104