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