a1c6960772ceb146b856e39a9d000cce07763b19
[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 and erased space'"
48
49 echo $plot_str
50  
51 while [ ! -e $done_file ]; do
52 sleep $plot_delay
53 tail -$plot_samples $log_file > $trunc_file
54 echo replot
55 done
56 }
57
58
59 rm -f $done_file
60 trap "touch $done_file" INT
61
62 echo "Start gathering task in background"
63 gather_data &
64 echo "Run plotting task"
65 drive_gnuplot | gnuplot
66
67 wait
68
69 echo "All done"
70