-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbenchmark.sh
executable file
·733 lines (615 loc) · 21.5 KB
/
benchmark.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
#!/bin/bash
# benchmark.sh
# Author: Nils Knieling - https://github.com/Cyclenerd/benchmark
#
# Bash Script which runs several Linux benchmarks (Sysbench, UnixBench and Geekbench)
#
# Currently only tested with Ubuntu. Should also work with every other Linux distribution.
# Please note the requirements. More information can be found in the README.md
#
cat << EOF
_ _ _ _
| | | | | | | |
| |__ ___ _ __ ___| |__ _ __ ___ __ _ _ __| | __ ___| |__
| '_ \ / _ \ _ \ / __| _ \| _ _ \ / _ | __| |/ / / __| _ \
| |_) | __/ | | | (__| | | | | | | | | (_| | | | < _\__ \ | | |
|_.__/ \___|_| |_|\___|_| |_|_| |_| |_|\__,_|_| |_|\_(_)___/_| |_|
EOF
#####################################################################
#### Configuration Section
#####################################################################
# Storage for downloaded files and IO / tests
# Typically $HOME (/root/benchmark) is a good place.
# You need approximately 10 GB of free space.
MY_DIR="$HOME/benchmark"
# Location for the HTML benchmark results
# This can also be $MY_DIR (/root/benchmark/output.html)
MY_OUTPUT="$MY_DIR/output.html"
# Benchmarks without package for Linux distribution
# These benchmark programs are loaded:
MY_UNIXBENCH_DOWNLOAD_URL="https://www.nkn-it.de/backup/byte-unixbench-5.1.3.tar.gz"
#MY_UNIXBENCH_DOWNLOAD_URL="https://github.com/kdlucas/byte-unixbench/archive/v5.1.3.tar.gz"
MY_GEEKBENCH_DOWNLOAD_URL="https://cdn.geekbench.com/Geekbench-5.4.5-Linux.tar.gz"
# Unlock Geekbench using EMAIL and KEY
# If you purchased Geekbench, enter your email address and license
# key from your email receipt with the following command line:
# benchmark.sh -e <EMAIL> -k <KEY>
# As an alternative you can also save your data as follows:
MY_GEEKBENCH_EMAIL=""
MY_GEEKBENCH_KEY=""
# GitHub API personal access token with scope `gist` (Create gists)
# benchmark.sh -g <TOKEN>
MY_GITHUB_API_TOKEN=""
MY_GITHUB_API_JSON="$MY_DIR/github-gist.json"
MY_GITHUB_API_LOG="$MY_DIR/github-gist.log"
# Set maximal traceroute hop count
MY_TRACEROUTE_MAX_HOP="15"
#####################################################################
#### END Configuration Section
#####################################################################
ME=$(basename "$0")
MY_DATE_TIME=$(date -u "+%Y-%m-%d %H:%M:%S")
MY_DATE_TIME+=" UTC"
MY_TIMESTAMP_START=$(date "+%s")
MY_GEEKBENCH_NO_UPLOAD=""
#####################################################################
# Terminal output helpers
#####################################################################
function usage {
returnCode="$1"
echo
echo -e "Usage:
$ME [-e <EMAIL>] [-k <KEY>] [-n] [-h]"
echo -e "Options:
[-e <EMAIL>]\\t unlock Geekbench using EMAIL and KEY (default: $MY_GEEKBENCH_EMAIL)
[-k <KEY>]\\t unlock Geekbench using EMAIL and KEY (default: $MY_GEEKBENCH_KEY)
[-n]\\t\\t do not upload results to the Geekbench Browser (only if unlocked)
[-g <TOKEN>]\\t GitHub API personal access token, create new gist with results (default: $MY_GEEKBENCH_KEY)
[-h]\\t\\t displays help (this message)"
echo
exit "$returnCode"
}
# echo_title() outputs a title to stdout and MY_OUTPUT
function echo_title() {
echo "> $1"
echo "<h1>$1</h1>" >> "$MY_OUTPUT"
}
# echo_step() outputs a step to stdout and MY_OUTPUT
function echo_step() {
echo " > $1"
echo "<h2>$1</h2>" >> "$MY_OUTPUT"
}
# echo_sub_step() outputs a step to stdout and MY_OUTPUT
function echo_sub_step() {
echo " > $1"
echo "<h3>$1</h3>" >> "$MY_OUTPUT"
}
# echo_code() outputs <pre> or </pre> to MY_OUTPUT
function echo_code() {
case "$1" in
start)
echo "<pre>" >> "$MY_OUTPUT"
;;
end)
echo "</pre>" >> "$MY_OUTPUT"
;;
esac
}
# echo_equals() outputs a line with =
function echo_equals() {
COUNTER=0
while [ $COUNTER -lt "$1" ]; do
printf '='
((COUNTER=COUNTER+1))
done
}
# echo_line() outputs a line with 70 =
function echo_line() {
echo_equals "90"
echo
}
# exit_with_failure() outputs a message before exiting the script.
function exit_with_failure() {
echo
echo "FAILURE: $1"
echo
exit 9
}
#####################################################################
# Other helpers
#####################################################################
# command_exists() tells if a given command exists.
function command_exists() {
command -v "$1" >/dev/null 2>&1
}
# perl_module_exists() tells if a given perl module exists.
function perl_module_exists() {
perl -M"$1" -e 1 >/dev/null 2>&1
}
# check_if_root_or_die() verifies if the script is being run as root and exits
# otherwise (i.e. die).
function check_if_root_or_die() {
SCRIPT_UID=$(id -u)
if [ "$SCRIPT_UID" != 0 ]; then
exit_with_failure "$ME should be run as root"
fi
}
# check_operating_system() obtains the operating system and exits if it's not testet
function check_operating_system() {
MY_UNAME_S="$(uname -s 2>/dev/null)"
if [ "$MY_UNAME_S" = "Linux" ]; then
echo " > Operating System: Linux"
else
exit_with_failure "Unsupported operating system 'MY_UNAME_S'. Please use 'Linux' or edit this script :-)"
fi
}
# hostname_fqdn() get full (FQDN) hostname
function hostname_fqdn() {
echo_step "Hostname (FQDN)"
if hostname -f &>/dev/null; then
hostname -f >> "$MY_OUTPUT"
elif hostname &>/dev/null; then
hostname >> "$MY_OUTPUT"
else
echo "Hostname could not be determined"
fi
}
# cpu_info() cat /proc/cpuinfo to MY_OUTPUT
function cpu_info() {
echo_step "CPU Info"
if [[ -f "/proc/cpuinfo" ]]; then
MY_CPU_COUNT=$(grep -c processor /proc/cpuinfo)
echo_code start
cat "/proc/cpuinfo" >> "$MY_OUTPUT"
echo_code end
else
exit_with_failure "'/proc/cpuinfo' does not exist"
fi
}
# mem_info() cat /proc/meminfo to MY_OUTPUT
function mem_info() {
echo_step "RAM Info"
if [[ -f "/proc/meminfo" ]]; then
echo_code start
cat "/proc/meminfo" >> "$MY_OUTPUT"
echo_code end
else
exit_with_failure "'/proc/meminfo' does not exist"
fi
echo_step "Free"
echo_code start
free -m >> "$MY_OUTPUT"
echo_code end
}
# network_info() cat /etc/resolv.conf to MY_OUTPUT
function network_info() {
echo_step "Network Card"
echo_code start
lspci -nnk | grep -i net -A2 >> "$MY_OUTPUT"
echo_code end
echo_step "Ifconfig"
echo_code start
ifconfig >> "$MY_OUTPUT"
echo_code end
echo_step "Nameserver"
if [[ -f "/etc/resolv.conf" ]]; then
echo_code start
cat "/etc/resolv.conf" >> "$MY_OUTPUT"
echo_code end
else
exit_with_failure "'/etc/resolv.conf' does not exist"
fi
}
# disk_info() df -h to MY_OUTPUT
function disk_info() {
echo_step "Disk Info"
echo_code start
df -h >> "$MY_OUTPUT"
echo_code end
}
# traceroute_benchmark() traceroute to MY_OUTPUT
function traceroute_benchmark() {
echo_step "Traceroute ($1)"
echo_code start
traceroute -m "$MY_TRACEROUTE_MAX_HOP" "$1" >> "$MY_OUTPUT" 2>&1
echo_code end
}
# ping_benchmark() ping to MY_OUTPUT
function ping_benchmark() {
echo_step "Ping ($1)"
echo_code start
ping -c 10 "$1" >> "$MY_OUTPUT" 2>&1
echo_code end
}
# download_benchmark() curl speed to MY_OUTPUT
function download_benchmark() {
echo_step "Download from $1 ($2)"
if MY_CURL_STATS=$(curl -f -w '%{speed_download}\t%{time_namelookup}\t%{time_total}\n' -o /dev/null -s "$2"); then
MY_CURL_SPEED=$(echo "$MY_CURL_STATS" | awk '{print $1}')
MY_CURL_DNSTIME=$(echo "$MY_CURL_STATS" | awk '{print $2}')
MY_CURL_TOTALTIME=$(echo "$MY_CURL_STATS" | awk '{print $3}')
echo_code start
{
echo "Speed: $MY_CURL_SPEED"
echo "DNS: $MY_CURL_DNSTIME sec"
echo "Total Time: $MY_CURL_TOTALTIME sec"
} >> "$MY_OUTPUT"
echo_code end
else
echo "Error"
fi
}
#####################################################################
# MAIN
#####################################################################
echo_line
while getopts "ne:k:g:h" opt; do
case $opt in
n)
MY_GEEKBENCH_NO_UPLOAD="1"
;;
e)
MY_GEEKBENCH_EMAIL="$OPTARG"
;;
k)
MY_GEEKBENCH_KEY="$OPTARG"
;;
g)
MY_GITHUB_API_TOKEN="$OPTARG"
;;
h)
usage 0
;;
*)
usage 1
;;
esac
done
#####################################################################
# Check the requirements
#
# These Ubuntu packages should be installed:
# curl
# make
# gcc
# build-essential
# net-tools
# traceroute
# perl
# lshw
# ioping
# fio
# sysbench
#####################################################################
echo "> Check the Requirements"
check_if_root_or_die
check_operating_system
if [[ ! -d "$MY_DIR" ]]; then
mkdir "$MY_DIR" || exit_with_failure "Could not create folder '$MY_DIR'"
fi
echo "<html>" > "$MY_OUTPUT" || exit_with_failure "Could not write to output file '$MY_OUTPUT'"
if ! command_exists curl; then
exit_with_failure "'curl' is needed. Please install 'curl'. More details can be found at https://curl.haxx.se/"
fi
if ! command_exists make; then
exit_with_failure "'make' is needed. Please install development tools (Ubuntu package 'build-essential') for your operating system."
fi
if ! command_exists gcc; then
exit_with_failure "'gcc' is needed. Please install development tools (Ubuntu package 'build-essential') for your operating system."
fi
if ! command_exists perl; then
exit_with_failure "'perl' is needed. Please install 'perl'. More details can be found at https://www.perl.org/get.html"
fi
if ! command_exists ifconfig; then
exit_with_failure "'ifconfig' is needed. Please install network tools (Ubuntu package 'net-tools') for your operating system."
fi
if ! command_exists ping; then
exit_with_failure "'ping' is needed. Please install network tools (Ubuntu package 'net-tools' and 'inetutils-ping') for your operating system."
fi
if ! command_exists lspci; then
exit_with_failure "'lspci' is needed. Please install network tools (Ubuntu package 'pciutils') for your operating system."
fi
if ! command_exists traceroute; then
exit_with_failure "'traceroute' is needed. Please install 'traceroute'."
fi
if ! command_exists dd; then
exit_with_failure "'dd' is needed. Please install 'dd'. More details can be found at https://www.gnu.org/software/coreutils/manual/"
fi
if ! command_exists lshw; then
exit_with_failure "'lshw' is needed. Please install 'lshw'. More details can be found at http://www.ezix.org/project/wiki/HardwareLiSter"
fi
if ! command_exists ioping; then
exit_with_failure "'ioping' is needed. Please install 'ioping'. More details can be found at https://github.com/koct9i/ioping"
fi
if ! command_exists fio; then
exit_with_failure "'fio' is needed. Please install 'fio'. More details can be found at https://wiki.mikejung.biz/Benchmarking#Fio_Installation"
fi
if ! command_exists sysbench; then
exit_with_failure "'sysbench' is needed. Please install 'sysbench'. More details can be found at https://github.com/akopytov/sysbench"
fi
if ! perl_module_exists "Time::HiRes"; then
exit_with_failure "Perl module 'Time::HiRes' is needed. Please install 'Time::HiRes'. More details can be found at http://www.cpan.org/modules/INSTALL.html"
fi
if ! perl_module_exists "IO::Handle"; then
exit_with_failure "Perl module 'IO::Handle' is needed. Please install 'IO::Handle'. More details can be found at http://www.cpan.org/modules/INSTALL.html"
fi
# Download and build UnixBench
echo " > Download UnixBench"
if curl -fsL "$MY_UNIXBENCH_DOWNLOAD_URL" -o "$MY_DIR/unixbench.tar.gz"; then
if tar xvfz "$MY_DIR/unixbench.tar.gz" -C "$MY_DIR" --strip-components=1 > /dev/null 2>&1; then
cd "$MY_DIR/UnixBench" || exit_with_failure "Could not find folder '$MY_DIR/UnixBench'"
if make > /dev/null 2>&1; then
echo " > UnixBench successfully downloaded and compiled"
else
exit_with_failure "Could not build (make) UnixBench"
fi
else
exit_with_failure "Could not unpack '$MY_DIR/unixbench.tar.gz'"
fi
else
exit_with_failure "Could not download UnixBench '$MY_UNIXBENCH_DOWNLOAD_URL'"
fi
# Download Geekbench 5
echo " > Download Geekbench 5"
if curl -fsL "$MY_GEEKBENCH_DOWNLOAD_URL" -o "$MY_DIR/geekbench.tar.gz"; then
if tar xvfz "$MY_DIR/geekbench.tar.gz" -C "$MY_DIR" --strip-components=1 > /dev/null 2>&1; then
if [[ -x "$MY_DIR/geekbench5" ]]; then
echo " > Geekbench successfully downloaded"
else
exit_with_failure "Could not find '$MY_DIR/geekbench5'"
fi
else
exit_with_failure "Could not unpack '$MY_DIR/geekbench.tar.gz'"
fi
else
exit_with_failure "Could not download Geekbench '$MY_GEEKBENCH_DOWNLOAD_URL'"
fi
# Unlock Geekbench 5
if [[ $MY_GEEKBENCH_EMAIL && $MY_GEEKBENCH_KEY ]]; then
if "$MY_DIR/geekbench5" --unlock "$MY_GEEKBENCH_EMAIL" "$MY_GEEKBENCH_KEY" > /dev/null 2>&1; then
echo " > Geekbench successfully unlocked"
else
exit_with_failure "Could not unlock Geekbench"
fi
else
echo " > Geekbench is in tryout mode"
fi
#####################################################################
# Let's start
#####################################################################
echo_line
echo
echo " Depending on the hardware, the runtime is slightly longer."
echo
echo " Please be patient..!"
echo
echo_line
#####################################################################
# Get System info and versions
#####################################################################
echo_title "System Info"
hostname_fqdn
echo_step "Kernel"; uname -a >> "$MY_OUTPUT"
echo_step "Date and Time"; echo "$MY_DATE_TIME" >> "$MY_OUTPUT"
echo_step "Hardware Lister (lshw)"
echo_code start
lshw >> "$MY_OUTPUT"
echo_code end
cpu_info
mem_info
network_info
#####################################################################
# Versions
#####################################################################
echo_step "Versions"
echo_sub_step "Bash"
echo "$BASH_VERSION" >> "$MY_OUTPUT"
echo_sub_step "gcc"
echo_code start
gcc -v >> "$MY_OUTPUT" 2>&1
echo_code end
echo_sub_step "make"
echo_code start
make -v >> "$MY_OUTPUT" 2>&1
echo_code end
echo_sub_step "Perl"
echo_code start
perl -v >> "$MY_OUTPUT" 2>&1
echo_code end
#####################################################################
# Run bandwidth benchmarks
#####################################################################
echo_title "Bandwidth Benchmark"
# Cachefly
ping_benchmark "cachefly.cachefly.net"
# Hetzner, Nuernberg, Germany
ping_benchmark "hetzner.de"
# Germany (Frankfurt)
ping_benchmark "ftp.hostserver.de"
# IPv6
ping_benchmark "ipv6.test-ipv6.com"
traceroute_benchmark "cachefly.cachefly.net"
traceroute_benchmark "hetzner.de"
traceroute_benchmark "ftp.hostserver.de"
download_benchmark 'Cachefly' 'http://cachefly.cachefly.net/100mb.test'
#download_benchmark 'Linode, Atlanta, GA, USA' 'http://speedtest.atlanta.linode.com/100MB-atlanta.bin'
#download_benchmark 'Linode, Dallas, TX, USA' 'http://speedtest.dallas.linode.com/100MB-dallas.bin'
#download_benchmark 'Linode, Tokyo, JP' 'http://speedtest.tokyo.linode.com/100MB-tokyo.bin'
#download_benchmark 'Linode, London, UK' 'http://speedtest.london.linode.com/100MB-london.bin'
#download_benchmark 'OVH, Paris, France' 'http://proof.ovh.net/files/100Mio.dat'
#download_benchmark 'SmartDC, Rotterdam, Netherlands' 'http://mirror.i3d.net/100mb.bin'
download_benchmark 'Hetzner, Nuernberg, Germany' 'http://speed.hetzner.de/100MB.iso'
#download_benchmark 'iiNet, Perth, WA, Australia' 'http://ftp.iinet.net.au/test100MB.dat'
#download_benchmark 'Leaseweb, Haarlem, NL' 'http://mirror.nl.leaseweb.net/speedtest/100mb.bin'
#download_benchmark 'Leaseweb, Manassas, VA, USA' 'http://mirror.us.leaseweb.net/speedtest/100mb.bin'
#download_benchmark 'Softlayer, Singapore' 'http://speedtest.sng01.softlayer.com/downloads/test100.zip'
#download_benchmark 'Softlayer, Seattle, WA, USA' 'http://speedtest.sea01.softlayer.com/downloads/test100.zip'
#download_benchmark 'Softlayer, San Jose, CA, USA' 'http://speedtest.sjc01.softlayer.com/downloads/test100.zip'
#download_benchmark 'Softlayer, Washington, DC, USA' 'http://speedtest.wdc01.softlayer.com/downloads/test100.zip'
#####################################################################
# Run I/O benchmarks
#####################################################################
echo_title "I/O Benchmark"
# DD
echo_step "dd 1Mx1k fdatasync"
echo_code start
MY_DD=$(dd if="/dev/zero" of="$MY_DIR/io-test" bs=1M count=1k conv=fdatasync 2>&1)
echo "$MY_DD" >> "$MY_OUTPUT"
echo_code end
echo_step "dd 64kx16k fdatasync"
echo_code start
MY_DD=$(dd if="/dev/zero" of="$MY_DIR/io-test" bs=64k count=16k conv=fdatasync 2>&1)
echo "$MY_DD" >> "$MY_OUTPUT"
echo_code end
echo_step "dd 1Mx1k dsync"
echo_code start
MY_DD=$(dd if="/dev/zero" of="$MY_DIR/io-test" bs=1M count=1k oflag=dsync 2>&1)
echo "$MY_DD" >> "$MY_OUTPUT"
echo_code end
echo_step "dd 64kx16k dsync"
echo_code start
MY_DD=$(dd if="/dev/zero" of="$MY_DIR/io-test" bs=64k count=16k oflag=dsync 2>&1)
echo "$MY_DD" >> "$MY_OUTPUT"
echo_code end
# IOPing
echo_step "IOPing"
echo_code start
ioping -c 10 "$MY_DIR/" >> "$MY_OUTPUT"
echo_code end
echo_step "IOPing seek rate"
echo_code start
ioping -RD "$MY_DIR/" >> "$MY_OUTPUT"
echo_code end
echo_step "IOPing sequential"
echo_code start
ioping -RL "$MY_DIR/" >> "$MY_OUTPUT"
echo_code end
echo_step "IOPing cached"
echo_code start
ioping -RC "$MY_DIR/" >> "$MY_OUTPUT"
echo_code end
# FIO
echo_step "FIO full write pass"
echo_code start
fio --name=writefile --size=10G --filesize=10G \
--filename="$MY_DIR/io-test" \
--bs=1M --nrfiles=1 \
--direct=1 --sync=0 --randrepeat=0 --rw=write --refill_buffers --end_fsync=1 \
--iodepth=200 --ioengine=libaio >> "$MY_OUTPUT"
echo_code end
echo_step "FIO rand read"
echo_code start
fio --time_based --name=benchmark --size=10G --runtime=30 \
--filename="$MY_DIR/io-test" \
--ioengine=libaio --randrepeat=0 \
--iodepth=128 --direct=1 --invalidate=1 --verify=0 --verify_fatal=0 \
--numjobs=4 --rw=randread --blocksize=4k --group_reporting >> "$MY_OUTPUT"
echo_code end
echo_step "FIO rand write"
echo_code start
fio --time_based --name=benchmark --size=10G --runtime=30 \
--filename="$MY_DIR/io-test" \
--ioengine=libaio --randrepeat=0 \
--iodepth=128 --direct=1 --invalidate=1 --verify=0 --verify_fatal=0 \
--numjobs=4 --rw=randwrite --blocksize=4k --group_reporting >> "$MY_OUTPUT"
echo_code end
#####################################################################
# Run SysBench
#####################################################################
echo_title "SysBench"
echo_step "SysBench Single-Core CPU performance test (1 thread)"
echo_code start
sysbench cpu --cpu-max-prime=20000 --threads=1 run >> "$MY_OUTPUT"
echo_code end
if [[ $MY_CPU_COUNT -gt "0" ]]; then
echo_step "SysBench Multi-Core CPU performance test ($MY_CPU_COUNT threads)"
echo_code start
sysbench cpu --cpu-max-prime=20000 --threads="$MY_CPU_COUNT" run >> "$MY_OUTPUT"
echo_code end
fi
echo_step "SysBench Memory functions speed test"
echo_code start
sysbench memory run >> "$MY_OUTPUT"
echo_code end
#####################################################################
# Run UnixBench
#####################################################################
echo_line
echo " Now let's run the good old UnixBench. This takes a while."
echo_line
echo_title "UnixBench"
echo_code start
perl "$MY_DIR/UnixBench/Run" -c "1" -c "$MY_CPU_COUNT" >> "$MY_OUTPUT" 2>&1
echo_code end
#####################################################################
# Run Geekbench 5
#####################################################################
echo_line
echo "Now let's run Geekbench 5. This takes a little longer."
echo_line
echo_title "Geekbench 5"
echo_code start
if [[ $MY_GEEKBENCH_NO_UPLOAD ]]; then
"$MY_DIR/geekbench5" --no-upload >> "$MY_OUTPUT" 2>&1
else
"$MY_DIR/geekbench5" --upload >> "$MY_OUTPUT" 2>&1
fi
echo_code end
#####################################################################
# Get uptime and load average
# http://en.wikipedia.org/wiki/Load_%28computing%29
#####################################################################
echo_title "Uptime (Load Average)"
echo_code start
uptime >> "$MY_OUTPUT" 2>&1
echo_code end
#####################################################################
# Calculate the complete duration (runtime)
#####################################################################
echo_title "Complete Duration"
MY_TIMESTAMP_END=$(date "+%s")
MY_DURATION_SEC=$((MY_TIMESTAMP_END-MY_TIMESTAMP_START))
MY_DURATION_MIN=$((MY_DURATION_SEC/60))
{
echo "<ul>"
echo " <li>Start: $MY_TIMESTAMP_START</li>"
echo " <li>End: $MY_TIMESTAMP_END</li>"
echo -n " <li><b>Duration: "; printf "%.0f sec / %.2f min" "$MY_DURATION_SEC" "$MY_DURATION_MIN"; echo "</b></li>"
echo "</ul>"
} >> "$MY_OUTPUT"
#####################################################################
# EOF
#####################################################################
{
echo "<hr>"
echo "$ME - $MY_DATE_TIME"
echo "</html>"
} >> "$MY_OUTPUT"
#####################################################################
# Create gist
#####################################################################
if [[ $MY_GITHUB_API_TOKEN ]]; then
echo " > Create new gist with HTML results"
MY_OUTPUT_CONTENT=$(sed -e 's/\r//' -e's/\t/\\t/g' -e 's/"/\\"/g' "$MY_OUTPUT" | awk '{ printf($0 "\\n") }')
MY_GIST_CONCENT="{\"description\":\"benchmark.sh output\",\"public\":false,\"files\":{\"$MY_TIMESTAMP_START.html\":{\"content\":\"$MY_OUTPUT_CONTENT\"}}}"
echo "$MY_GIST_CONCENT" > "$MY_GITHUB_API_JSON"
if curl -X POST -H "Authorization: token $MY_GITHUB_API_TOKEN" -d @"$MY_GITHUB_API_JSON" "https://api.github.com/gists" >> "$MY_GITHUB_API_LOG" 2>&1; then
echo " > Upload successful"
else
echo " > Upload failed"
fi
fi
#####################################################################
# DONE
#####################################################################
echo
echo_line
echo
echo " D O N E"
echo
echo " HTML file for analysis:"
echo " $MY_OUTPUT"
echo
echo_line
echo
exit 0