-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
benchmark
executable file
·62 lines (54 loc) · 1.81 KB
/
benchmark
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
#!/bin/bash
# small CPU/MEM/DSK/NET benchmark for linux/macos
# alex@aiei.ch
# for cpu, openssl speed is also nice
# check if called binaries are available
for a in date memtester bc dd sync printf speedtest-cli; do
which $a >/dev/null
if [ ! $? -eq 0 ]; then
echo $a not found
exit 1
fi
done
d=date
which gdate >/dev/null && d=$(which gdate)
# MEMORY 16 MB
echo -n "MEM "
which free >/dev/null && m=$(free -b |grep ^Mem: |awk '{printf "%.0f\n", $2/1024/1024/1024}')
which free >/dev/null || m=$(sysctl -n hw.memsize|awk '{printf "%.0f\n", $1/1024/1024/1024}')
start=$($d +%s.%N)
memtester 16M 1 &>/dev/null
end=$($d +%s.%N)
printf "[%.2f\"/%s GB]\n" $(echo $end - $start | bc) $m
# CPU, single core, (3000 digits of pi)
echo -n "CPU "
arch=$(uname -m)
cores=$(getconf _NPROCESSORS_ONLN)
start=$($d +%s.%N)
/bin/echo "scale=3000;4*a(1)" | bc -l &>/dev/null
end=$($d +%s.%N)
printf "[%.2f\"/%s/%s]\n" $(echo $end - $start | bc) $cores $arch
# DISK 6.4 GB
echo -n "DSK "
start=$($d +%s.%N)
l=$(pwd)
dd=M
if [ $(uname) = Darwin ]; then dd=m; fi
if [ -d /scratch ]; then l=/scratch; fi
which diskutil >/dev/null && disk=$(diskutil info /dev/disk0|grep "Disk Size:" | awk '{print $3}')
which diskutil >/dev/null || disk=$(df -BG $l | tail -1 | awk '{print $2}'| sed s,G,,)
# check if there's enough diskspace, compare value above with num
freemb=`df -m $l | tail -1 | awk '{print $4}'`
if [ 6400 -gt $freemb ]; then
echo 6.4 GB diskspace needed, but only $freemb MB found.
exit 1
fi
sync;dd if=/dev/zero of=$l/_benchmark bs=64${dd} count=100 &>/dev/null;rm $l/_benchmark;sync
end=$($d +%s.%N)
printf "[%.2f\"/%.0f GB]\n" $(echo $end - $start | bc) $disk
# NETWORK
echo -n "NET "
start=$($d +%s.%N)
s=$(speedtest-cli --bytes --simple | tail -2)
end=$($d +%s.%N)
printf "[%.2f\"] %s\n" $(echo $end - $start | bc) "$(echo $s)"