summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2016-10-20 22:32:50 +0200
committerStefan Sauer <ensonic@users.sf.net>2016-11-14 21:18:53 +0100
commit06ce912ba6d21527fda54299b3e7a1909fcf3cbf (patch)
tree70b521ca58803927b83083b7c9aff59fe1deae85 /scripts
parentae608845ca83ab02c5a386285375c36778874151 (diff)
scripts/gst-plot-traces.sh: make log parsing a bit more solid
Use grep -o to grab the log message only. This makes it work with colored log files too. Prefilter the log to not catch tracer classes. Update the commandline for the script in the docs.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gst-plot-traces.sh18
1 files changed, 11 insertions, 7 deletions
diff --git a/scripts/gst-plot-traces.sh b/scripts/gst-plot-traces.sh
index 0580cfd00..180864912 100755
--- a/scripts/gst-plot-traces.sh
+++ b/scripts/gst-plot-traces.sh
@@ -1,7 +1,6 @@
#!/bin/bash
# dumps a gnuplot script to stdout that plot of the given log
-
usage="\
Usage:$0 [--title=<title>] [--log=<log>] [--format={png,pdf,ps,svg}] [--pagesize={a3,a4}]| gnuplot"
@@ -31,10 +30,15 @@ tmp=`mktemp -d`
plot_width=1600
plot_height=1200
+base=`basename "$log" ".log"`
+
# filter log
-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
-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
-( cd $tmp; awk -F" " '{ print $1, $3, $4, $5 >"cpu_thread."$2".dat" }' cpu_threads.dat )
+grep "TRACE" $log | grep "GST_TRACER" >$tmp/trace.log
+log=$tmp/trace.log
+
+grep -o "proc-rusage,.*" $log | cut -c14- | sed -e 's#process-id=(guint64)[0-9][0-9]*, ##' -e 's#ts=(guint64)##' -e 's#[a-z]*-cpuload=(uint)##g' -e 's#time=(guint64)##' -e 's#;##' -e 's#, # #g' >$tmp/cpu_proc.dat
+grep -o "thread-rusage,.*" $log | cut -c35- | 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' >$tmp/cpu_threads.dat
+( cd $tmp; awk -F" " '{ print $2, $3, $4, $5 >"cpu_thread."$1".dat" }' cpu_threads.dat )
# configure output
# http://en.wikipedia.org/wiki/Paper_size
@@ -52,7 +56,7 @@ case $format in
svg) echo "set term svg size $plot_width,$plot_height font \"Sans,7\"";;
esac
cat <<EOF
-set output '$log.cpu.$format'
+set output '$base.cpu.$format'
set xlabel "Time (ns)"
set ylabel "Per-Mille"
set grid
@@ -60,7 +64,7 @@ plot \\
'$tmp/cpu_proc.dat' using 1:2 with lines title 'avg cpu', \\
'' using 1:3 with lines title 'cur cpu'
-set output '$log.thread.$format'
+set output '$base.thread.$format'
set xlabel "Time (ns)"
set ylabel "Per-Mille"
set grid
@@ -74,7 +78,7 @@ for file in $tmp/cpu_thread.*.dat ; do
id=`echo $file | sed 's#.*cpu_thread.\([0-9]*\).dat#\1#'`
cat <<EOF
'$file' using 1:2 with lines title '$id avg cpu', \\
- '' using 1:3 with lines title '$id cur cpu', \\
+ '' using 1:3 with lines title '$id cur cpu', \\
EOF
done
cat <<EOF