Sort out Linux kernel building with new driver model.
[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         xx='1'
29         erased_blocks='2'
30         while [ "$xx" !=  "$erased_blocks" ] ; do
31                 xx=$(cat /proc/yaffs | grep n_erased_blocks | cut -d ' ' -f 2)
32                 erased_blocks=$(cat /proc/yaffs | grep n_erased_blocks | cut -d ' ' -f 2)
33                 if [ -z "$xx" ] ; then
34                         xx='bad value'
35                 fi
36         done
37         xx='1'
38         free_chunks='2'
39         while [ "$xx" != "$free_chunks" ] ; do
40                 xx=$(cat /proc/yaffs | grep n_free_chunks | cut -d ' ' -f 2)
41                 free_chunks=$(cat /proc/yaffs | grep n_free_chunks | cut -d ' ' -f 2)
42                 if [ -z "$xx" ] ; then
43                         xx='bad value'
44                 fi
45         done
46         erased_chunks=$(($erased_blocks*64))
47         str=" $i, 0, $free_chunks, $erased_chunks"
48         echo $str
49         echo $str  >> $log_file
50         i=$(($i+1))
51         sleep $gather_delay
52 done
53 }
54
55
56 # Plotting task
57 # Periodically creates a truncated version of the log file and
58 # outputs commands into gnuplot, thus driving gnuplot
59
60 drive_gnuplot(){
61 sleep 5
62 tail -$plot_samples $log_file > $trunc_file
63
64 plot_str=" plot '$trunc_file' using 1:3 with linespoints title 'free', '' using 1:4 with linespoints title 'erased'"
65
66 echo "set title 'yaffs free space vs erased space'"
67 echo "set xlabel 'seconds'"
68 echo "set ylabel 'chunks'"
69
70
71 echo $plot_str
72  
73 while [ ! -e $done_file ]; do
74 sleep $plot_delay
75 tail -$plot_samples $log_file > $trunc_file
76 echo replot
77 done
78 }
79
80
81 rm -f $done_file
82 trap "touch $done_file" INT
83
84 echo "Start gathering task in background"
85 gather_data &
86 echo "Run plotting task"
87 drive_gnuplot | gnuplot
88
89 wait
90
91 echo "All done"
92