-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-bench.sh
executable file
·96 lines (88 loc) · 3.36 KB
/
simple-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
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
disk_latency_test() {
local sample_count=${1:-3}
local container_image=${2:-"host"}
local label=${3:-""}
local prefix_cmd="timeout --kill-after=30s 2m "
for iter in $(seq 1 ${sample_count}); do
echo "--> From ${container_image^} ${label} ${iter}/${sample_count}"
echo "------------------------------"
if [ "hostx" == "${container_image}x" ]; then
test_filename="${PWD}/test512kb_zero_${container_image%:*}_${iter}.data"
test_cmd="time -p dd if=/dev/zero of=${test_filename} bs=512 count=1000 conv=fdatasync "
${prefix_cmd} ${test_cmd}
else
test_filename="/mnt/test512kb_zero_$(basename ${container_image%%:*})_${iter}.data"
test_cmd="time -p dd if=/dev/zero of=${test_filename} bs=512 count=1000 conv=fdatasync "
docker_cmd="docker run --rm -v $PWD/:/mnt -w /mnt ${container_image} bash -c "
${prefix_cmd} ${docker_cmd} "${test_cmd}"
fi
sync -f
echo "------------------------------"
echo
done
}
disk_throughput_test() {
local sample_count=${1:-3}
local container_image=${2:-"host"}
local label=${3:-""}
local prefix_cmd="timeout --kill-after=30s 2m "
for iter in $(seq 1 ${sample_count}); do
echo "--> From ${container_image^} ${label} ${iter}/${sample_count}"
echo "------------------------------"
if [ "hostx" == "${container_image}x" ]; then
test_filename="${PWD}/test1G_zero_$(basename ${container_image%%:*})_${iter}.data"
test_cmd="time -p dd if=/dev/zero of=${test_filename} bs=1G count=1 conv=fdatasync "
${prefix_cmd} ${test_cmd}
else
test_filename="/mnt/test1G_zero_$(basename ${container_image%%:*})_${iter}.data"
test_cmd="time -p dd if=/dev/zero of=${test_filename} bs=1G count=1 conv=fdatasync "
docker_cmd="docker run --rm -v $PWD/:/mnt -w /mnt ${container_image} bash -c "
${prefix_cmd} ${docker_cmd} "${test_cmd}"
fi
sync -f
echo "------------------------------"
echo
done
}
cpu_speed_test() {
local sample_count=${1:-3}
local container_image=${2:-"host"}
local label=${3:-""}
local prefix_cmd="timeout --kill-after=30s 2m "
for iter in $(seq 1 ${sample_count}); do
echo "--> From ${container_image^} ${label} ${iter}/${sample_count}"
echo "------------------------------"
test_cmd='dd if=/dev/zero bs=1M count=1024 | md5sum'
if [ "hostx" == "${container_image}x" ]; then
${prefix_cmd} bash -c "${test_cmd}"
else
docker_cmd="docker run --rm -v $PWD/:/mnt -w /mnt ${container_image} bash -c "
${prefix_cmd} ${docker_cmd} "${test_cmd}"
fi
sync -f
echo "------------------------------"
echo
done
}
echo "Testing performance"
echo "--------------------"
echo
echo "Executing Simple CPU Benchmark: 1000 blocks of 1M filled by Zeros sent to md5sum"
echo
cpu_speed_test 3
cpu_speed_test 3 'debian:jessie' 'x86_64'
cpu_speed_test 3 'multiarch/debian-debootstrap:armhf-jessie' 'ARM'
echo "Executing disk write test for Latency: 1000 blocks of 512B filled by Zeros"
echo
disk_latency_test 3
disk_latency_test 3 'debian:jessie' 'x86_64'
disk_latency_test 3 'multiarch/debian-debootstrap:armhf-jessie' 'ARM'
echo "Executing disk write test for throughput: 1 block of 1GB filled by Zeros"
echo
disk_throughput_test 3
disk_throughput_test 3 'debian:jessie' 'x86_64'
disk_throughput_test 3 'multiarch/debian-debootstrap:armhf-jessie' 'ARM'
echo
echo "Cleaning up"
rm -f *.data