-
Notifications
You must be signed in to change notification settings - Fork 16
/
linux-bench.sh
executable file
·672 lines (548 loc) · 14.7 KB
/
linux-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
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
#!/bin/bash
#
# Linux-Bench CPU Benchmark Script
# (C) 2013-2017 ServeTheHome.com and ServeThe.biz
#
# Linux-Bench - A System benchmark and comparison tool created by the STH community.
#
# Linux-Bench is a sscript that runs hardinfo, Unixbench 5.1.3, c-ray 1.1, STREAM, OpenSSL, sysbench (CPU),
# crafty, redis, NPB, NAMD, and 7-zip benchmarks without manual intervention.
#
# Linux-Bench must be run as root or using a su prompt to automate download and installation of benchmarks
#
# For more information go:
# http://linux-bench.com
#
# Authors: Patrick Kennedy, Charles Nguyen (Chuckleb), Patriot, nitrobass24, mir, Frank DiDonato (LOGiCELL, Inc.)
#
# Latest development versions are available on the GitHub site: https://github.com/STH-Dev/linux-bench/
#
# If you find bugs, verify you are on the latest version and then post in:
# https://forums.servethehome.com/index.php?forums/linux-bench/
#
# To view your results, check the reference ID at the end of the log file generated. You can copy and paste
# the ID number here: http://linux-bench.com/parser.html and see parsed results.
################################################################################################################################
#Current Version
rev='12.19'
version()
{
cat << EOF
##############################################################
# (c) 2013-2017 ServeTheHome.com and ServeThe.biz
#
# Linux-Bench $rev
# - Linux-Bench the STH Benchmark Suite
###############################################################
EOF
}
usage()
{
cat << EOF
usage: $0
This is the STH benchmark suite.
ARGS:
ARG1 - none required for now
ARG2 - none required for now
ARG3 - none required for now
OPTIONAL ARGS:
ARG -- script_option_1 script_option-2
OPTIONS:
-h help (usage info)
-V Version of Linux-Bench
-p Private Result, results will not be in the public database
-e Email results, a perfect pairing with private results.
use -e [email protected]
ENVIRONMENT VARIABLES:
VIRTUAL = If unset, value is FALSE. Set to TRUE if running virtualized (automatically set for Docker)
EOF
}
# Verify if the script is executed with Root Privileges #
rootcheck()
{
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
echo "Ex. "sudo ./linux-bench.sh""
exit 1
fi
}
#Set Functions
setup()
{
benchdir=`pwd`
NEED_PTS=1
date_str="+%Y_%m%d_%H%M%S"
full_date=`date $date_str`
host=$(hostname)
log="linux-bench"$rev"_"$host"_"$full_date.log
if [ -f /.dockerinit ] ; then
log=/data/"linux-bench"$rev"_"$host"_"$full_date.log
fi
if [ -n "$isprivate" ]; then
echo $isprivate
fi
if [ -n "$email" ]; then
echo $email
fi
#outdir=$host"_"$full_date
#mkdir $outdir
}
# Update and install required packages (Debian)
Update_Install_Debian()
{
apt-get update
apt-get -y install build-essential libx11-dev libglu-dev hardinfo sysbench unzip expect php7.0-curl php7.0-common php7.0-cli php7.0-gd libfpdi-php gfortran curl
mkdir -p /usr/tmp/
rm /etc/apt/sources.list.d/linuxbench.list
}
# Update and install required packages (CentOS/RHEL)
Update_Install_RHEL()
{
rpm -Uhv http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uhv http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
yum -y groupinstall "Development Tools" && yum -y install wget sysbench unzip libX11 perl-Time-HiRes mesa-libGLU hardinfo expect php-common glibc.i686 gfortran curl
}
# Detects which OS and if it is Linux then it will detect which Linux Distribution.
whichdistro()
{
OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
DIST=Solaris
ARCH=`uname -p`
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif [ "${OS}" = "AIX" ] ; then
DIST=AIX
OSSTR="${OS} `oslevel` (`oslevel -r`)"
elif [ "${OS}" = "Linux" ] ; then
KERNEL=`uname -r`
if [ -f /etc/redhat-release ] ; then
DIST='RedHat'
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/centos-release ] ; then
DIST='CentOS'
PSUEDONAME=`cat /etc/centos-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/centos-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
elif [ -f /etc/mandrake-release ] ; then
DIST='Mandrake'
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ] ; then
DIST="Debian"
PSUEDONAME=`cat /etc/debian_version`
REV=""
if [ `grep DISTRIB_ID= /etc/lsb-release | cut -d"=" -f2` = "Ubuntu" ] ; then
DIST="Ubuntu"
UBUNTU_RELEASE=`lsb_release -sc`
REPO1="deb http://us.archive.ubuntu.com/ubuntu/ "
REPO1END=" universe"
echo $REPO1 $UBUNTU_RELEASE $REPO1END > /etc/apt/sources.list.d/linuxbench.list
fi
elif [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
else
DIST='Not detected'
fi
OSSTR="${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})"
fi
}
# Update and install required packages
dlDependancies()
{
if [ -f /.dockerinit ] ; then
echo "In a Docker container, no updates run."
VIRTUAL="TRUE"
elif [ "${DIST}" = "CentOS" ] ; then
Update_Install_RHEL
elif [ "${DIST}" = "RedHat" ] ; then
Update_Install_RHEL
elif [ "${DIST}" = "Debian" ] || [ "${DIST}" = "Ubuntu" ] ; then
Update_Install_Debian
fi
}
# Display script output and append to log
benchlog()
{
exec > >(tee --append $log)
echo $ref >> $log
exec 2>&1
echo ${OSSTR}
}
extract()
{
if [ -e ./$appbin ] ; then
echo "$apptgz already installed"
elif [ -e ./$apptgz ] ; then
tar $tgzstring $apptgz
else
wget $appdlpath
tar $tgzstring $apptgz
fi
}
#System information and log capture.
sysinfo()
{
eval "strings `which lscpu`" | grep -q version ;
if [ $? = 0 ] ; then
lscpu
lscpu -V
lscpu -e
else
lscpu;
fi
: ${VIRTUAL:=FALSE}
echo "VIRTUAL="$VIRTUAL
# Check to see if the CPU is an Intel/AMD or ARM
# This is a simple check for now.
cpu_check=$(grep 'CPU architecture' /proc/cpuinfo)
if [ $? -ne 0 ] ; then
CPU=x86
else
CPU=ARM;
fi
echo "CPU="$CPU
echo "Linux-Bench Version="$rev
}
proc_define()
{
# Physical sockets
sockets=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)
# Physical Cores
if [[ $CPU == "x86" ]] ; then
procs=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)
pcores=$(grep "cpu cores" /proc/cpuinfo |sort -u |cut -d":" -f2)
cores=$((procs*pcores))
elif [[ $CPU == "ARM" ]] ; then
cores=$(grep "processor" /proc/cpuinfo | wc -l)
else
echo "Unknown CPU"
fi
# Virtual Cores (include threads)
vcores=$(grep "processor" /proc/cpuinfo | wc -l)
threads=$vcores
nproc=$vcores
}
# HardInfo
hardi()
{
cd $benchdir
echo "Running HardInfo test"
hardinfo --generate-report --report-format text
}
# UnixBench 5.1.3
ubench()
{
cd $benchdir
echo "Building UnixBench"
wget -N http://files.linux-bench.com/lb/UnixBench5.1.3.tgz
wget -N http://files.linux-bench.com/lb/fix-limitation.patch
tar -zxf UnixBench5.1.3.tgz
cd UnixBench
mv ../fix-limitation.patch .
make -j$(nproc)
patch Run fix-limitation.patch
echo "Running UnixBench"
./Run dhry2reg whetstone-double syscall pipe context1 spawn execl shell1 shell8 shell16
cd $benchdir
rm -rf UnixBench* fix-limitation.patch
}
# C-Ray 1.1
cray()
{
cd $benchdir
appbase=c-ray-1.1
apptgz=c-ray-1.1.gz
tgzstring=xfz
appbin=$appbase/c-ray-mt
appdlpath=http://files.linux-bench.com/lb/$apptgz
extract
echo "Running C-Ray test"
cd c-ray-1.1 && make
echo "c-ray Easy Test"
cat scene | ./c-ray-mt -t $threads -s 7500x3500 > foo.ppm
echo "c-ray Medium Test"
cat sphfract | ./c-ray-mt -t $threads -s 1920x1200 -r 8 > foo.ppm
echo "c-ray Hard Test"
cat sphfract | ./c-ray-mt -t $threads -s 3840x2160 -r 8 > foo.ppm
cd $benchdir
rm -rf $appbase*
}
# STREAM by Dr. John D. McCalpin
stream()
{
cd $benchdir
echo "Building STREAM"
if [ -e stream.c ] ; then
echo "Stream downloaded"
else
wget -N http://www.cs.virginia.edu/stream/FTP/Code/stream.c
fi
gcc stream.c -O3 -march=native -fopenmp -o stream-me
export OMP_NUM_THREADS=$cores
export GOMP_CPU_AFFINITY=0-$((cores-1))
echo $GOMP_CPU_AFFINITY
echo "Running STREAM test"
./stream-me
cd $benchdir
rm -rf stream-me stream.c
}
# OpenSSL
OSSL()
{
cd $benchdir
appbase=openssl-1.0.1g
apptgz=openssl-1.0.1g.tar.gz
tgzstring=xfz
appbin=$appbase/apps/openssl
appdlpath=http://www.openssl.org/source/$apptgz
extract
cd openssl-1.0.1g/
echo "Building OpenSSL"
./config no-zlib >> /dev/null 2>&1
make >> /dev/null 2>&1
echo "Running OpenSSL test"
./apps/openssl speed rsa4096 -multi $nproc
cd $benchdir
rm -rf openssl*
}
crafty()
{
cd $benchdir
wget -N http://www.craftychess.com/crafty-23.4.zip
unzip -o crafty-23.4.zip
cd crafty-23.4/
export target=LINUX
export CFLAGS="-Wall -pipe -O3 -fomit-frame-pointer $CFLAGS"
export CXFLAGS="-Wall -pipe -O3 -fomit-frame-pointer"
export LDFLAGS="$LDFLAGS -lstdc++"
make crafty-make
chmod +x crafty
./crafty bench end
cd $benchdir
rm -rf crafty*
}
# sysbench CPU test prime
sysb()
{
cd $benchdir
echo "Running sysbench CPU Single Thread"
sysbench --test=cpu --cpu-max-prime=30000 run
echo "Running sysbench CPU Multi-Threaded"
sysbench --num-threads=$nproc --test=cpu --cpu-max-prime=300000 run
}
# redis Benchmark based on feedback. Next step is to add memchached as seen here: http://oldblog.antirez.com/post/redis-memcached-benchmark.html
red()
{
cd $benchdir
echo "Building Redis"
wget http://download.redis.io/redis-stable.tar.gz
tar xzf redis-stable.tar.gz && cd redis-stable && make install
cp utils/redis_init_script /etc/init.d/redis_6379
mkdir -p /var/redis/6379
wget http://files.linux-bench.com/lb/6379.conf
mkdir -p /etc/redis
cp ./6379.conf /etc/redis
service redis_6379 start
# Original redis benchmark set/ get test
echo "Running Redis test"
redis-benchmark -n 1000000 -t set,get -P 32 -q -c 200
BIN=redis-benchmark
payload=32
iterations=10000
keyspace=100000
for clients in 1 5 10 25 50 75 100
do
SPEED=0
for dummy in 0 1 2
do
S=$($BIN -n $iterations -r $keyspace -d $payload -c $clients | grep 'per second' | tail -1 | awk '{print $1}')
VALUE=$(echo $S | awk '{printf "%.0f",$1}')
if [ $(($VALUE > $SPEED)) != 0 ]
then
SPEED=$VALUE
fi
done
echo "$clients $SPEED"
done
redis-cli shutdown
cd $benchdir
rm -rf redis* /etc/redis /var/redis* /usr/local/bin/redis-* /etc/init.d/redis_*
}
# NPB Benchmarks
NPB()
{
cd $benchdir
apptgz=NPB3.3.1.tar.gz
appbin=NPB3.3.1/NPB3.3-OMP
appdlpath=http://files.linux-bench.com/lb/$apptgz
tgzstring=xfz
extract
cd NPB3.3.1/NPB3.3-OMP/
echo "Building NPB"
# Use the provided makefile definitions
cp config/NAS.samples/make.def.gcc_x86 config/make.def
# Define which tests to build
echo "ft A" >> config/suite.def
#echo "mg A" >> config/suite.def
#echo "sp A" >> config/suite.def
#echo "lu A" >> config/suite.def
echo "bt A" >> config/suite.def
#echo "is A" >> config/suite.def
#echo "ep A" >> config/suite.def
#echo "cg A" >> config/suite.def
#echo "ua A" >> config/suite.def
#echo "dc A" >> config/suite.def
make suite
export OMP_NUM_THREADS=$cores
echo "Running NPB tests"
bin/bt.A.x
bin/ft.A.x
cd $benchdir
rm -rf NPB*
}
# NAMD Benchmark http://www.ks.uiuc.edu/Research/namd/performance.html
NAMD()
{
echo "Building NAMD"
cd $benchdir
appbase=NAMD_2.9_Linux-x86_64-multicore
apptgz=NAMD_2.9_Linux-x86_64-multicore.tar.gz
tgzstring=xfz
appbin=$appbase/namd2
appdlpath=http://files.linux-bench.com/lb/$apptgz
extract
appbase=apoa1
apptgz=apoa1.tar.gz
tgzstring=xfz
appbin=$appbase/apoa1.pdb
appdlpath=http://files.linux-bench.com/lb/$apptgz
extract
echo "Using" $threads "threads"
echo "Running NAMD benchmark... (will take a while)"
cd NAMD_2.9_Linux-x86_64-multicore
timeperstep=$(./namd2 +p$threads +setcpuaffinity ../apoa1/apoa1.namd | grep "Benchmark time" | tail -1 | cut -d" " -f6)
echo "Time per step" $timeperstep
cd $benchdir
rm -rf NAMD* apoa1*
}
# p7zip
p7zip()
{
cd $benchdir
appbase=p7zip_9.20.1
apptgz=p7zip_9.20.1_src_all.tar.bz2
tgzstring=xfj
appbin=p7zip_9.20.1/bin/7za
appdlpath=http://files.linux-bench.com/lb/$apptgz
extract
echo "Building p7zip"
cd $appbase
make >> /dev/null 2>&1
echo "Starting 7zip benchmark, this will take a while"
bin/7za b >> output.txt
compressmips=$(grep Avr output.txt | tr -s ' ' |cut -d" " -f4)
decompressmips=$(grep Avr output.txt | tr -s ' ' |cut -d" " -f7)
echo "Compress speed (MIPS):" $compressmips
echo "Decompress speed (MIPS):" $decompressmips
cd $benchdir
rm -rf p7zip*
}
runBenches()
{
#Individual modules run below...comment them out to prevent them from running.
#echo ${iterations:=1} passes
# while [ $iterations -gt 0 ] ; do
echo "hardinfo"
time hardi
echo "ubench"
time ubench
echo "cray"
time cray
echo "stream"
time stream
echo "OSSL"
time OSSL
echo "sysbench"
time sysb
echo "redis"
time red
echo "NPB"
time NPB
echo "NAMD"
time NAMD
echo "p7zip"
time p7zip
# let iterations-=1
# done
}
# Runtime This is where everything is actually run from and called...
#
# This is where a menu would go for runtime options...
#
main()
{
rootcheck
while getopts "hVRpe:" arg; do
case $arg in
h)
usage
exit 1
;;
V)
version
exit 1
;;
p)
isprivate="Private Result"
;;
e)
email="Send Linux-Bench result to: $OPTARG"
;;
\?)
usage
exit 1
;;
esac
done
echo "setup"
setup
echo "version"
version
echo "whichdistro"
whichdistro
echo "dlDep"
dlDependancies
echo "benchlog"
benchlog
echo "derpinfo"
sysinfo exiting on sysinfo...
sysinfo
echo "proc_define"
proc_define
echo "run benches"
runBenches
echo "done"
}
push_data() {
ref=$(date +%S%d$i%s)
echo "ref_link: $ref"
echo "See your results online at: http://linux-bench.com/display/$ref"
mkdir tmpbench && cp $log tmpbench/.
sleep 1s
# curl -F file="@./tmpbench/$log" http://parser.linux-bench.com:3000/java-process/uploader -H "Connection: close"
curl --form file="@./tmpbench/$log" --form press=Upload http://beta.linux-bench.com/upload_file/ --trace-ascii dumpfile
#Adding new script targets
curl --form file="@./tmpbench/$log" --form press=Upload http://linux-bench.com/upload_file/ --trace-ascii dumpfile
# curl -F file="@./tmpbench/$log" http://linux-bench.com:3000/java-process/uploader -H "Connection: close"
rm -rf ./tmpbench/
echo "ref_link: $ref"
}
# Execute everything in the script
main
push_data