1.自动化测试脚本unixbench
yum install -y wget
wget --no-check-certificate https://github.com/teddysun/across/raw/master/unixbench.sh
chmod +x unixbench.sh
./unixbench.sh
115.231.102.80:
Double-Precision Whetstone 17086.1 MWIPS (10.0 s, 7 samples)
Execl Throughput 14392.7 lps (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 476888.5 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 136850.5 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 983756.4 KBps (30.0 s, 2 samples)
Pipe Throughput 6399569.2 lps (10.0 s, 7 samples)
Pipe-based Context Switching 1416599.5 lps (10.0 s, 7 samples)
Process Creation 30040.1 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 14900.7 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 2484.1 lpm (60.1 s, 2 samples)
System Call Overhead 2247922.5 lps (10.0 s, 7 samples)
System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 152391926.4 13058.4
Double-Precision Whetstone 55.0 17086.1 3106.6
Execl Throughput 43.0 14392.7 3347.1
File Copy 1024 bufsize 2000 maxblocks 3960.0 476888.5 1204.3
File Copy 256 bufsize 500 maxblocks 1655.0 136850.5 826.9
File Copy 4096 bufsize 8000 maxblocks 5800.0 983756.4 1696.1
Pipe Throughput 12440.0 6399569.2 5144.3
Pipe-based Context Switching 4000.0 1416599.5 3541.5
Process Creation 126.0 30040.1 2384.1
Shell Scripts (1 concurrent) 42.4 14900.7 3514.3
Shell Scripts (8 concurrent) 6.0 2484.1 4140.2
System Call Overhead 15000.0 2247922.5 1498.6
========
System Benchmarks Index Score 2784.5
======= Script description and score comparison completed! =======
********
CPU
[root@ecloud log]# sysbench --test=cpu --num-threads=500 --cpu-max-prime=2000 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.6 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 500
Initializing random number generator from current time
Prime numbers limit: 2000
Initializing worker threads...
Threads started!
General statistics:
total time: 10.0111s
total number of events: 279414
Latency (ms):
min: 0.14
avg: 14.11
max: 3849.15
95th percentile: 0.15
sum: 3942001.48
Threads fairness:
events (avg/stddev): 558.8280/159.04
execution time (avg/stddev): 7.8840/1.41
2.sysbench测试工具
[root@hd1_live_video_test12 ~]# sysbench --test=cpu --num-threads=500 --cpu-max-prime=2000 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.6 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 500
Initializing random number generator from current time
Prime numbers limit: 2000
Initializing worker threads...
Threads started!
General statistics:
total time: 10.0298s
total number of events: 146550
Latency (ms):
min: 0.10
avg: 31.56
max: 2434.14
95th percentile: 0.19
sum: 4625765.20
Threads fairness:
events (avg/stddev): 293.1000/20.06
execution time (avg/stddev): 9.2515/0.46
program
[root@ecloud log]# sysbench --test=threads --num-threads=500 --thread-yields=100 --thread-locks=4 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.6 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 500
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 10.0242s
total number of events: 183556
Latency (ms):
min: 0.03
avg: 27.27
max: 505.66
95th percentile: 121.08
sum: 5005451.78
Threads fairness:
events (avg/stddev): 367.1120/33.10
[root@hd1_live_video_test12 ~]# sysbench --test=threads --num-threads=500 --thread-yields=100 --thread-locks=4 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.6 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 500
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 10.0351s
total number of events: 180507
Latency (ms):
min: 0.00
avg: 27.74
max: 717.29
95th percentile: 106.75
sum: 5006797.73
Threads fairness:
events (avg/stddev): 361.0140/18.77
execution time (avg/stddev): 10.0136/0.01
测试磁盘IO:
准备测试文件:
sysbench --test=fileio --num-threads=16 --file-total-size=2G --file-test-mode=rndrw prepare
[root@ecloud ~]# sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.6 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 20
Initializing random number generator from current time
Extra file open flags: 0
128 files, 16MiB each
2GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...
Threads started!
File operations:
reads/s: 4372.96
writes/s: 2915.30
fsyncs/s: 9322.08
Throughput:
read, MiB/s: 68.33
written, MiB/s: 45.55
General statistics:
total time: 10.0004s
total number of events: 166143
Latency (ms):
min: 0.00
avg: 1.20
max: 95.72
95th percentile: 3.43
sum: 199829.97
Threads fairness:
events (avg/stddev): 8307.1500/361.33
execution time (avg/stddev): 9.9915/0.00
[root@hd1_live_video_test12 ~]# sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.6 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 20
Initializing random number generator from current time
Extra file open flags: 0
128 files, 16MiB each
2GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...
Threads started!
File operations:
reads/s: 1762.77
writes/s: 1175.51
fsyncs/s: 3753.91
Throughput:
read, MiB/s: 27.54
written, MiB/s: 18.37
General statistics:
total time: 10.0039s
total number of events: 66961
Latency (ms):
min: 0.00
avg: 2.99
max: 96.62
95th percentile: 8.28
sum: 199961.64
Threads fairness:
events (avg/stddev): 3348.0500/129.33
execution time (avg/stddev): 9.9981/0.00
3.一键自动化测试脚本bench.sh
总结一下 bench.sh 特点:
1、显示当前测试的各种系统信息;
2、取自世界多处的知名数据中心的测试点,下载测试比较全面;
3、支持 IPv6 下载测速;
4、IO 测试三次,并显示平均值。
再配合 unixbench.sh 脚本测试,即可全面测试 VPS 的性能。
使用方法:
命令1:
wget -qO- bench.sh | bash
# ok
curl -Lso- bench.sh | bash
命令2:
wget -qO- 86.re/bench.sh | bash
curl -so- 86.re/bench.sh | bash
备注:
bench.sh 既是脚本名,同时又是域名。所以不要怀疑我写错了或者你看错了。
一键测试脚本:
#!/usr/bin/env bash
#
# Description: Auto test download & I/O speed script
#
#
if [ ! -e '/usr/bin/wget' ]; then
echo "Error: wget command not found. You must be install wget command at first."
exit 1
fi
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
PLAIN='\033[0m'
get_opsy() {
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
}
next() {
printf "%-70s\n" "-" | sed 's/\s/-/g'
}
speed_test() {
local speedtest=$(wget -4O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
local ipaddress=$(ping -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
local nodeName=$2
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "${nodeName}" "${ipaddress}" "${speedtest}"
}
speed_test_v6() {
local speedtest=$(wget -6O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
local ipaddress=$(ping6 -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
local nodeName=$2
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "${nodeName}" "${ipaddress}" "${speedtest}"
}
speed() {
speed_test 'http://cachefly.cachefly.net/100mb.test' 'CacheFly'
speed_test 'http://speedtest.tokyo.linode.com/100MB-tokyo.bin' 'Linode, Tokyo, JP'
speed_test 'http://speedtest.singapore.linode.com/100MB-singapore.bin' 'Linode, Singapore, SG'
speed_test 'http://speedtest.london.linode.com/100MB-london.bin' 'Linode, London, UK'
speed_test 'http://speedtest.frankfurt.linode.com/100MB-frankfurt.bin' 'Linode, Frankfurt, DE'
speed_test 'http://speedtest.fremont.linode.com/100MB-fremont.bin' 'Linode, Fremont, CA'
speed_test 'http://speedtest.dal05.softlayer.com/downloads/test100.zip' 'Softlayer, Dallas, TX'
speed_test 'http://speedtest.sea01.softlayer.com/downloads/test100.zip' 'Softlayer, Seattle, WA'
speed_test 'http://speedtest.fra02.softlayer.com/downloads/test100.zip' 'Softlayer, Frankfurt, DE'
speed_test 'http://speedtest.sng01.softlayer.com/downloads/test100.zip' 'Softlayer, Singapore, SG'
speed_test 'http://speedtest.hkg02.softlayer.com/downloads/test100.zip' 'Softlayer, HongKong, CN'
}
speed_v6() {
speed_test_v6 'http://speedtest.atlanta.linode.com/100MB-atlanta.bin' 'Linode, Atlanta, GA'
speed_test_v6 'http://speedtest.dallas.linode.com/100MB-dallas.bin' 'Linode, Dallas, TX'
speed_test_v6 'http://speedtest.newark.linode.com/100MB-newark.bin' 'Linode, Newark, NJ'
speed_test_v6 'http://speedtest.singapore.linode.com/100MB-singapore.bin' 'Linode, Singapore, SG'
speed_test_v6 'http://speedtest.tokyo.linode.com/100MB-tokyo.bin' 'Linode, Tokyo, JP'
speed_test_v6 'http://speedtest.sjc03.softlayer.com/downloads/test100.zip' 'Softlayer, San Jose, CA'
speed_test_v6 'http://speedtest.wdc01.softlayer.com/downloads/test100.zip' 'Softlayer, Washington, WA'
speed_test_v6 'http://speedtest.par01.softlayer.com/downloads/test100.zip' 'Softlayer, Paris, FR'
speed_test_v6 'http://speedtest.sng01.softlayer.com/downloads/test100.zip' 'Softlayer, Singapore, SG'
speed_test_v6 'http://speedtest.tok02.softlayer.com/downloads/test100.zip' 'Softlayer, Tokyo, JP'
}
io_test() {
(LANG=C dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'
}
calc_disk() {
local total_size=0
local array=$@
for size in ${array[@]}
do
[ "${size}" == "0" ] && size_t=0 || size_t=`echo ${size:0:${#size}-1}`
[ "`echo ${size:(-1)}`" == "K" ] && size=0
[ "`echo ${size:(-1)}`" == "M" ] && size=$( awk 'BEGIN{printf "%.1f", '$size_t' / 1024}' )
[ "`echo ${size:(-1)}`" == "T" ] && size=$( awk 'BEGIN{printf "%.1f", '$size_t' * 1024}' )
[ "`echo ${size:(-1)}`" == "G" ] && size=${size_t}
total_size=$( awk 'BEGIN{printf "%.1f", '$total_size' + '$size'}' )
done
echo ${total_size}
}
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
tram=$( free -m | awk '/Mem/ {print $2}' )
uram=$( free -m | awk '/Mem/ {print $3}' )
swap=$( free -m | awk '/Swap/ {print $2}' )
uswap=$( free -m | awk '/Swap/ {print $3}' )
up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days, %d hour %d min\n",a,b,c)}' /proc/uptime )
load=$( w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
opsy=$( get_opsy )
arch=$( uname -m )
lbit=$( getconf LONG_BIT )
kern=$( uname -r )
ipv6=$( wget -qO- -t1 -T2 ipv6.icanhazip.com )
disk_size1=($( LANG=C df -ahPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $2}' ))
disk_size2=($( LANG=C df -ahPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $3}' ))
disk_total_size=$( calc_disk ${disk_size1[@]} )
disk_used_size=$( calc_disk ${disk_size2[@]} )
clear
next
echo "CPU model : $cname"
echo "Number of cores : $cores"
echo "CPU frequency : $freq MHz"
echo "Total size of Disk : $disk_total_size GB ($disk_used_size GB Used)"
echo "Total amount of Mem : $tram MB ($uram MB Used)"
echo "Total amount of Swap : $swap MB ($uswap MB Used)"
echo "System uptime : $up"
echo "Load average : $load"
echo "OS : $opsy"
echo "Arch : $arch ($lbit Bit)"
echo "Kernel : $kern"
next
io1=$( io_test )
echo "I/O speed(1st run) : $io1"
io2=$( io_test )
echo "I/O speed(2nd run) : $io2"
io3=$( io_test )
echo "I/O speed(3rd run) : $io3"
ioraw1=$( echo $io1 | awk 'NR==1 {print $1}' )
[ "`echo $io1 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw1=$( awk 'BEGIN{print '$ioraw1' * 1024}' )
ioraw2=$( echo $io2 | awk 'NR==1 {print $1}' )
[ "`echo $io2 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw2=$( awk 'BEGIN{print '$ioraw2' * 1024}' )
ioraw3=$( echo $io3 | awk 'NR==1 {print $1}' )
[ "`echo $io3 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw3=$( awk 'BEGIN{print '$ioraw3' * 1024}' )
ioall=$( awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}' )
ioavg=$( awk 'BEGIN{printf "%.1f", '$ioall' / 3}' )
echo "Average I/O speed : $ioavg MB/s"
next
printf "%-32s%-24s%-14s\n" "Node Name" "IPv4 address" "Download Speed"
speed && next
if [[ "$ipv6" != "" ]]; then
printf "%-32s%-24s%-14s\n" "Node Name" "IPv6 address" "Download Speed"
speed_v6 && next
fi
***
测试aliyun双核8G内存云主机:
test12_aliyun_2 cpu 8 G memory
[root@hd1_live_video_test12 data]# curl -Lso- bench.sh | bash
----------------------------------------------------------------------
CPU model : Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
Number of cores : 2
CPU frequency : 2593.748 MHz
Total size of Disk : 60.0 GB (6.1 GB Used)
Total amount of Mem : 7872 MB (5308 MB Used)
Total amount of Swap : 0 MB (0 MB Used)
System uptime : 16 days, 15 hour 29 min
Load average : 0.08, 0.17, 0.08
OS : CentOS 6.8
Arch : x86_64 (64 Bit)
Kernel : 2.6.32-642.6.2.el6.x86_64
----------------------------------------------------------------------
I/O speed(1st run) : 56.4 MB/s
I/O speed(2nd run) : 55.6 MB/s
I/O speed(3rd run) : 56.2 MB/s
Average I/O speed : 56.1 MB/s
----------------------------------------------------------------------
Node Name IPv4 address Download Speed
CacheFly 204.93.150.152 300KB/s
Linode, Tokyo, JP 106.187.96.148 16.8MB/s
Linode, Singapore, SG 139.162.23.4 42.5KB/s
Linode, London, UK 176.58.107.39 9.12MB/s
Linode, Frankfurt, DE 139.162.130.8 9.07MB/s
Linode, Fremont, CA 50.116.14.9 1.92MB/s
Softlayer, Dallas, TX 173.192.68.18 12.0MB/s
Softlayer, Seattle, WA 67.228.112.250 4.97MB/s
Softlayer, Frankfurt, DE 159.122.69.4 3.96MB/s
Softlayer, Singapore, SG 119.81.28.170 31.1KB/s
Softlayer, HongKong, CN 119.81.130.170 29.8KB/s