-
Notifications
You must be signed in to change notification settings - Fork 11
/
check_perfs.sh
executable file
·43 lines (34 loc) · 1.02 KB
/
check_perfs.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
#!/bin/bash
# Basic check to test for CPU and IO performances
RET=0
export LC_NUMERIC="C.UTF-8"
for cpu in /sys/devices/system/cpu/cpu*; do
if [ -f "$cpu/cpufreq/cpuinfo_cur_freq" ]; then
cpuid=$(basename "$cpu")
cur=$(cat "$cpu/cpufreq/cpuinfo_cur_freq")
min=$(cat "$cpu/cpufreq/cpuinfo_min_freq")
if [ "$cur" -lt "$min" ]; then
echo "WARNING : $cpuid current frequency ($cur Mhz) is lower than min frequency ($min Mhz)"
RET=1
fi
fi
done
test_command () {
c=$1
t=$2
TIMEFORMAT=%R
TIME=$( { time $c > /dev/null; } 2>&1 | sed 's/,/./g' )
#echo "$TIME"
if (( $(echo "$TIME > $t" |bc -l) )); then
echo "WARNING : \`$c\` took ${TIME}s (should be <${t}s)"
RET=1
fi
}
test_command pydf 1
tmpfile=$(mktemp /tmp/check_perfs.XXXXXX)
test_command "dd if=/dev/zero of=$tmpfile bs=1024 count=2000 status=none" 0.05
test_command "python3 -c 'var=1+1'" 0.5
if [ $RET -eq 0 ]; then
echo "OK : Everything seems fine."
fi
exit $RET