dcc1de3c951f8ee68fec238bfae663eb0e9854bf
[yaffs2.git] / linux-tests / plot_data.sh
1 #!/bin/sh
2 # Script that gathers data erased vs free data from /proc/yaffs_stats and simultaneously \
3 # plots it using gnuplot.
4
5
6 #Gather settings
7 log_file=data
8 gather_delay=1
9
10 done_file=plot_done
11
12 # Plot settings
13 trunc_file=trunc_data
14 plot_samples=1000
15 plot_delay=2
16
17
18
19
20
21 # Gathering task
22
23 gather_data() {
24 i=0;
25 rm -f $log_file
26
27 while [ ! -e $done_file ] ; do
28 str=$(cat /proc/yaffs_stats)
29 echo "$i, $str" 
30 echo "$i, $str"  >> $log_file
31 i=$(($i+1))
32 sleep $gather_delay
33 done
34 }
35
36
37 # Plotting task
38 # Periodically creates a truncated version of the log file and
39 # outputs commands into gnuplot, thus driving gnuplot
40
41 drive_gnuplot(){
42 sleep 5
43 tail -$plot_samples $log_file > $trunc_file
44
45 plot_str=" plot '$trunc_file' using 1:3 with linespoints title 'free', '' using 1:4 with linespoints title 'erased'"
46
47 echo "set title 'yaffs free space vs erased space'"
48 echo "set xlabel 'seconds'"
49 echo "set ylabel 'chunks'"
50
51
52 echo $plot_str
53  
54 while [ ! -e $done_file ]; do
55 sleep $plot_delay
56 tail -$plot_samples $log_file > $trunc_file
57 echo replot
58 done
59 }
60
61
62 rm -f $done_file
63 trap "touch $done_file" INT
64
65 echo "Start gathering task in background"
66 gather_data &
67 echo "Run plotting task"
68 drive_gnuplot | gnuplot
69
70 wait
71
72 echo "All done"
73