X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=linux-tests%2Fplot_data.sh;h=a1c6960772ceb146b856e39a9d000cce07763b19;hp=23a22024c15ff90408fab6b7483b37e88014374a;hb=f2d455470f1677828cf1c4fc74b64592edb79139;hpb=1f4323687427e7b156a7391bea3f1f4e55d90838 diff --git a/linux-tests/plot_data.sh b/linux-tests/plot_data.sh index 23a2202..a1c6960 100755 --- a/linux-tests/plot_data.sh +++ b/linux-tests/plot_data.sh @@ -1,5 +1,70 @@ #!/bin/sh -# plot_data.sh runs the plot, updating it in realtime +# Script that gathers data erased vs free data from /proc/yaffs_stats and simultaneously \ +# plots it using gnuplot. -./drive_gnuplot.sh | gnuplot + +#Gather settings +log_file=data +gather_delay=1 + +done_file=plot_done + +# Plot settings +trunc_file=trunc_data +plot_samples=1000 +plot_delay=2 + + + + + +# Gathering task + +gather_data() { +i=0; +rm -f $log_file + +while [ ! -e $done_file ] ; do +str=$(cat /proc/yaffs_stats) +echo "$i, $str" +echo "$i, $str" >> $log_file +i=$(($i+1)) +sleep $gather_delay +done +} + + +# Plotting task +# Periodically creates a truncated version of the log file and +# outputs commands into gnuplot, thus driving gnuplot + +drive_gnuplot(){ +sleep 5 +tail -$plot_samples $log_file > $trunc_file + +plot_str=" plot '$trunc_file' using 1:3 with linespoints title 'free', '' using 1:4 with linespoints title 'erased'" + +echo "set title 'yaffs free space and erased space'" + +echo $plot_str + +while [ ! -e $done_file ]; do +sleep $plot_delay +tail -$plot_samples $log_file > $trunc_file +echo replot +done +} + + +rm -f $done_file +trap "touch $done_file" INT + +echo "Start gathering task in background" +gather_data & +echo "Run plotting task" +drive_gnuplot | gnuplot + +wait + +echo "All done"