-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathmake_bench.sh
84 lines (72 loc) · 2.25 KB
/
make_bench.sh
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
78
79
80
81
82
83
84
#!/bin/bash
# prework: untar the linux kernel source of your choosing, create a .config
# then tar it up and define the tarballs basename in the 'source' variable below
# hint:
# cd linux-6.10.10
# make x86_64_defconfig
# cd ..
# tar cf linux-6.10.10 linux-6.10.10.tar
#
# define the other commented variable to match your system
#
# location of files on physical disk
test_path="/incoming"
# where to do the test - select a ramdisk (tmpfs) to min hdd usage
ramdisk="/scratch/bench"
# name of the tarball containing the preconfigured linux source in gz format
source="linux-6.10.10"
# make flags for benchmark
MAKEFLAGS='-j33'
# number of times to run benchmark knowing that the first run will be dropped (warm up)
limit=13
#####
NAME=$(uname -r)
RUNDATE=$(date "+%F %T")
do_bzimage() {
bench=bzImage
echo "Running Make..."
echo "Kernel: $NAME"
echo
echo "Unpacking source..."
[[ ! -d "$ramdisk/$source" ]] ; tar xf "$test_path/$source.tar" -C "$ramdisk"
cd "$ramdisk/$source" || exit 1
[[ ! -f "$test_path/results.csv" ]] && echo "run #,hostname,kernel,benchmark,time(sec),date" > "$test_path/results.csv"
x=0
echo "Starting benchmark; status will update as benchmark progresses."
while [ $x -lt $limit ]; do
x=$(( x + 1 ))
make clean &>/dev/null
begin=$(date +%s.%N)
sleep 1s
make $MAKEFLAGS bzImage &>/dev/null || exit
end=$(date +%s.%N)
diff=$(echo "scale=6; $end - $begin" | bc)
simpdiff=$(echo "scale=2; $end - $begin" | bc)
runsleft=$(echo "scale=2; $limit-$x"| bc)
secleft=$(echo "scale=2; $runsleft*$diff"|bc)
minleft=$(echo "scale=2; $runsleft*$diff/60"|bc)
eta=$(date -d "($date) $secleft sec" +%r)
echo "Run $x/$limit took $simpdiff seconds. ETA: $eta or about $minleft min from now."
if [[ $x -eq 1 ]]; then
# do not report the warmup run
true
else
echo "$x,$HOSTNAME,$NAME,$bench,$diff,$RUNDATE" >> $test_path/results.csv
fi
done
cd "$ramdisk" && rm -rf "${ramdisk:?}/${source:?}"
echo
echo "Benchmark done. Find results in $test_path/results.csv"
}
XSRUNNING=$(pidof xfce4-screensaver)
[[ -n "$XSRUNNING" ]] && kill "$XSRUNNING"
[[ ! -d $ramdisk ]] && mkdir -p $ramdisk
case "$1" in
b)
do_bzimage
;;
*)
echo "$0 {b}"
exit 0
;;
esac