2 # dumps a gnuplot script to stdout that plot of the given log
6 Usage:$0 [--title=<title>] [--log=<log>] [--format={png,pdf,ps,svg}] [--pagesize={a3,a4}]| gnuplot"
9 title="GStreamer trace"
14 # process commandline options
15 # @todo: add support for single letter options
18 X--version) echo "0.1"; exit 0;;
19 X--help) echo "$usage"; exit 0;;
20 X--title=*) title=`echo $1 | sed s/.*=//`; shift;;
21 X--log=*) log=`echo $1 | sed s/.*=//`; shift;;
22 X--format=*) format=`echo $1 | sed s/.*=//`; shift;;
23 X--pagesize=*) pagesize=`echo $1 | sed s/.*=//`; shift;;
35 grep "proc-rusage," $log | cut -c154- | sed -e 's#ts=(guint64)##' -e 's#[a-z]*-cpuload=(uint)##g' -e 's#time=(guint64)##' -e 's#;##' -e 's#, # #g' | sort -n >$tmp/cpu_proc.dat
36 grep "thread-rusage," $log | cut -c156- | sed -e 's#ts=(guint64)##' -e 's#thread-id=(uint)##g' -e 's#[a-z]*-cpuload=(uint)##g' -e 's#time=(guint64)##' -e 's#;##' -e 's#, # #g' | sort -n >$tmp/cpu_threads.dat
37 ( cd $tmp; awk -F" " '{ print $1, $3, $4, $5 >"cpu_thread."$2".dat" }' cpu_threads.dat )
40 # http://en.wikipedia.org/wiki/Paper_size
42 a3) page_with="29.7 cm";page_height="42.0 cm";;
43 a4) page_with="21.0 cm";page_height="29.7 cm";;
45 # http://www.gnuplot.info/docs/node341.html (terminal options)
47 # this doen't like fonts
48 png) echo "set term png truecolor font \"Sans,7\" size $plot_width,$plot_height";;
49 # pdf makes a new page for each plot :/
50 pdf) echo "set term pdf color font \"Sans,7\" size $page_with,$page_height";;
51 ps) echo "set term postscript portrait color solid \"Sans\" 7 size $page_with,$page_height";;
52 svg) echo "set term svg size $plot_width,$plot_height font \"Sans,7\"";;
55 set output '$log.cpu.$format'
56 set xlabel "Time (ns)"
57 set ylabel "Per-Mille"
60 '$tmp/cpu_proc.dat' using 1:2 with lines title 'avg cpu', \\
61 '' using 1:3 with lines title 'cur cpu'
63 set output '$log.thread.$format'
64 set xlabel "Time (ns)"
65 set ylabel "Per-Mille"
69 for file in $tmp/cpu_thread.*.dat ; do
70 ct=`cat $file | wc -l`
71 if [ $ct -lt 100 ]; then
74 id=`echo $file | sed 's#.*cpu_thread.\([0-9]*\).dat#\1#'`
76 '$file' using 1:2 with lines title '$id avg cpu', \\
77 '' using 1:3 with lines title '$id cur cpu', \\