yaffs Move docs to other repository
[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 # Plot settings
11 trunc_file=trunc_data
12 plot_samples=1000
13 plot_delay=2
14
15
16
17 # Gathering task
18
19 gather_data() {
20 i=0;
21 rm -f $log_file
22
23 while true; do
24 str=$(cat /proc/yaffs_stats)
25 echo "$i, $str" 
26 echo "$i, $str"  >> $log_file
27 let i=$i+1
28 sleep $gather_delay
29 done
30 }
31
32
33 # Plotting task
34 # Periodically creates a truncated version of the log file and
35 # outputs commands into gnuplot, thus driving gnuplot
36
37 drive_gnuplot(){
38 sleep 5
39 tail -$plot_samples $log_file > $trunc_file
40
41 plot_str=" plot '$trunc_file' using 1:3 with linespoints title 'free', '' using 1:4 with linespoints title 'erased'"
42
43 echo "set title 'yaffs free space and erased space'"
44
45 echo $plot_str
46  
47 while true; do
48 sleep $plot_delay
49 tail -$plot_samples $log_file > $trunc_file
50 echo replot
51 done
52 }
53
54
55
56 echo "Start gathering task in background"
57 gather_data &
58 echo "Run plotting task"
59 drive_gnuplot | gnuplot
60