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