-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-sysbench.sh
executable file
·74 lines (64 loc) · 2.14 KB
/
run-sysbench.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
#!/bin/sh
#
# run-sysbench.sh
#
# Run a complete suite of sysbench performance benchmarks
#
# Copyright (C) 2019 by The Obscure Organization
# MIT licensed. See the LICENSE file for details.
NUM_THREADS=8
run_sysbench() {
threads="$1"
for test in cpu memory mutex; do
echo "----- Running sysbench for $test -----"
sysbench --test="$test" run
done
for mode in seqwr seqrewr seqrd rndrd rndwr rndrw; do
echo "----- Running sysbench for fileio, mode=$mode -----"
sysbench --test=fileio --file-test-mode="$mode" prepare
sysbench --test=fileio --file-test-mode="$mode" run
done
echo "----- Running sysbench for threads -----"
sysbench --test=threads --num-threads="$threads" run
if [ -n "$(command -v mysql)" ]; then
echo "----- Running sysbench for oltp -----"
mysql -u root -e 'drop database if exists sbtest; create database sbtest'
if sysbench --test=oltp prepare --db-driver=mysql --mysql-user=root; then
sysbench --test=oltp run --db-driver=mysql --mysql-user=root
fi
else
echo "----- No mysql detected, skipping oltp -----"
fi
}
capture_env() {
os="$(uname -a | tr '[:upper:]' '[:lower:]')"
echo "current working directory (sysbench creates files here): '$(pwd)' -----"
echo "uname: '$(uname))"
echo "----- environment details -----"
uname
case "$os" in
darwin)
system_profiler 2>/dev/null | grep -iE 'Model Name|Model Identifier|Processor Name|Processor Speed|Number of Processors|Total Number of Cores|L[23] Cache|Memory:|Boot ROM|Serial Number|Hardware UUID'
;;
linux)
cat /proc/cpuinfo && \
cat /proc/interrupts && \
cat /proc/meminfo && \
cat /proc/diskstats
;;
*)
echo "WARNING: Unrecognized OS, skipping extra diagnostic output"
;;
esac
}
storagetype=${1?Enter a storage type: disk or ssd}
# Thanks Stack Overflow https://stackoverflow.com/a/7216394
ts=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
hostname=$(hostname)
logfile=sysbench-"$hostname-$storagetype-$ts".txt
rm -f "$logfile"
(
time capture_env && \
time run_sysbench "$NUM_THREADS"
) >> "$logfile" 2>&1
echo "----- see '$logfile' for benchmark output -----"