性能测试之UnixBench

折腾VPS的人总是会纠结一下自己的VPS性能怎么样,除了查看下VPS的系统信息之外,我们也会通过跑分软件来测试,比如使用Linux性能测试UnixBench跑分来测试。

UnixBench 是一款开源的测试 unix 系统基本性能的工具,是比较通用的测试VPS性能的工具.。UnixBench会执行一系列的测试,包括2D和3D图形系统的性能衡量,测试的结果不仅仅只是CPU,内存,或者磁盘为基准,还取决于硬件,操作系统版本,编译器.。测试系统各个方面一系列的性能,然后将每个测试结果和一个基准值进行比较,得到一个索引值,所有测试项目的索引值结合在一起形成一个测试分数值.

UNIXBENCH也是linux、unix测试系统基准性能的经典工具,UNIXBENCH测试包含了系统调用、读写、进程、2D、3D、管道、运算、C库等系统基准性能,它的优点在于提供了对系统性能的一种评价体系,为系统评分,如此方便对系统作对比测试;但UNIXBENCH在网络性能测试欠缺


1 更新yum源


国内源:可以使用wget获取或者直接下载
网易:
Centos5: http://mirrors.163.com/.help/CentOS5-Base-163.repo
Centos6: http://mirrors.163.com/.help/CentOS6-Base-163.repo
Centos7: http://mirrors.163.com/.help/CentOS7-Base-163.repo

中科大的yum源:
Centos5: https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=1
Centos6: https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=2
Centos7: https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=3

sohu的yum源:
http://mirrors.sohu.com/help/CentOS-Base-sohu.repo


进入yum源配置目录
 【cd /etc/yum.repos.d/】

下载yum源,以下载163的yum为例
【wget http://mirrors.163.com/.help/CentOS6-Base-163.repo】


下载后,将yum源配置目录下其他yum源设为不可用

【mv CentOS-Media.repo CentOS-Media.repo.bak】

接下来就可以正常使用了,


2 使用UnixBench


今天有在阿里云服务器跑分的时候出现"Can't locate Time/HiRes.pm in @INC"错误提示无法进行,检测是出现缺少perl Time HiRes组件造成的,并不是所有的UnixBench跑分的时候都会遇到这样的问题。

更新组件

【yum -y  install perl-Time-HiRes】


下载UnixBench  unixbench-5.1.2.tar.gz

安装:

unixbench5包含system和graphic测试,如果你需要测试graphic,则需要修改Makefile,不要注释掉"GRAPHIC_TESTS = defined,同时需要系统提供x11perf命令gl_glibs库。进入源包,执行【make】

使用:

执行system测试方法:Run
◆   执行graphic测试方法:Run graphics
◆   执行system,graphics测试方法:Run gindex


对于多cpu系统的性能测试策略,需要统计单任务,多任务及其并行的性能增强。
以4个cpu的PC为例,需要测试两次,4个CPU就是要并行执行4个copies,
【Run -c 1 -c 4】表示执行两次,第一次单个copies,第二次4个copies的测试任务。


结果分析

【System Benchmarks Index Score                                         171.3】

【System Benchmarks Index Score                                         395.7】

从上面的测试结果可以看出,但个并行的任务的得分为171.3,4个并行任务的得分为395.7。对比测试时需要关注这个值。

3 另一种简单的使用方法

UnixBench是一个类unix系(Unix,BSD,Linux)统下的性能测试工具,一个开源工具,被广泛用与测试linux系统主机的性能。Unixbench的主要测试项目有:系统调用、读写、进程、图形化测试、2D、3D、管道、运算、C库等系统基准性能提供测试数据。
最新版本UnixBench5.1.3,包含system和graphic测试,如果你需要测试graphic,则需要修改Makefile,不要注释掉”GRAPHIC_TESTS = defined”,同时需要系统提供x11perf命令gl_glibs库。
下面的脚本使用了最新版UnixBench5.1.3来测试,注释了关于graphic的测试项(大多数VPS都是没有显卡或者是集显,所以图像性能无需测试),运行10-30分钟后(根据CPU内核数量,运算时间不等)得出分数,越高越好。


 
 
  1. wget --no-check-certificate https:/ /github.com/teddysun /across/raw /master/unixbench.sh
  2. chmod +x unixbench.sh
  3. ./unixbench.sh

通过查看 unixbench.sh内容,本质还是第二种方法,只是让用户省去了很多繁琐的步骤


 
 
  1. #! /bin/bash
  2. #==============================================================#
  3. # Description: Unixbench script #
  4. # Author: Teddysun <i@teddysun.com> #
  5. # Intro: https://teddysun.com/245.html #
  6. #==============================================================#
  7. cur_dir=/opt/unixbench
  8. # Check System
  9. [[ $EUID -ne 0 ]] && echo 'Error: This script must be run as root!' && exit 1
  10. [[ -f /etc/redhat-release ]] && os= 'centos'
  11. [[ ! -z "`egrep -i debian /etc/issue`" ]] && os= 'debian'
  12. [[ ! -z "`egrep -i ubuntu /etc/issue`" ]] && os= 'ubuntu'
  13. [[ "$os" == '' ]] && echo 'Error: Your system is not supported to run it!' && exit 1
  14. # Install necessary libaries
  15. if [ "$os" == 'centos' ]; then
  16. yum -y install make automake gcc autoconf gcc-c++ time perl-Time-HiRes
  17. else
  18. apt-get -y update
  19. apt-get -y install make automake gcc autoconf time perl
  20. fi
  21. # Create new soft download dir
  22. mkdir -p ${cur_dir}
  23. cd ${cur_dir}
  24. # Download UnixBench5.1.3
  25. if [ -s UnixBench5.1.3.tgz ]; then
  26. echo "UnixBench5.1.3.tgz [found]"
  27. else
  28. echo "UnixBench5.1.3.tgz not found!!!download now..."
  29. if ! wget -c http://dl.teddysun.com/files/UnixBench5.1.3.tgz; then
  30. echo "Failed to download UnixBench5.1.3.tgz, please download it to ${cur_dir} directory manually and try again."
  31. exit 1
  32. fi
  33. fi
  34. tar -zxvf UnixBench5.1.3.tgz && rm -f UnixBench5.1.3.tgz
  35. cd UnixBench/
  36. #Run unixbench
  37. make
  38. ./Run
  39. echo
  40. echo
  41. echo "======= Script description and score comparison completed! ======= "
  42. echo
  43. echo

4 测试项目

Dhrystone 2 using register variables
此项用于测试 string handling,因为没有浮点操作,所以深受软件和硬件设计(hardware and software design)、编译和链接(compiler and linker options)、代码优化(code optimazaton)、对内存的cache(cache memory)、等待状态(wait states)、整数数据类型(integer data types)的影响。

Double-Precision Whetstone
这一项测试浮点数操作的速度和效率。这一测试包括几个模块,每个模块都包括一组用于科学计算的操作。覆盖面很广的一系列 c 函数:sin,cos,sqrt,exp,log 被用于整数和浮点数的数学运算、数组访问、条件分支(conditional branch)和程序调用。此测试同时测试了整数和浮点数算术运算。

Execl Throughput
此测试考察每秒钟可以执行的 execl 系统调用的次数。 execl 系统调用是 exec 函数族的一员。它和其他一些与之相似的命令一样是 execve() 函数的前端。

File copy
测试从一个文件向另外一个文件传输数据的速率。每次测试使用不同大小的缓冲区。这一针对文件 read、write、copy 操作的测试统计规定时间(默认是 10s)内的文件 read、write、copy 操作次数。

Pipe Throughput
管道(pipe)是进程间交流的最简单方式,这里的 Pipe throughtput 指的是一秒钟内一个进程可以向一个管道写 512 字节数据然后再读回的次数。需要注意的是,pipe throughtput 在实际编程中没有对应的真实存在。

Pipe-based Context Switching
这个测试两个进程(每秒钟)通过一个管道交换一个不断增长的整数的次数。这一点很向现实编程中的一些应用,这个测试程序首先创建一个子进程,再和这个子进程进行双向的管道传输。

Process Creation
测试每秒钟一个进程可以创建子进程然后收回子进程的次数(子进程一定立即退出)。process creation 的关注点是新进程进程控制块(process control block)的创建和内存分配,即一针见血地关注内存带宽。一般说来,这个测试被用于对操作系统进程创建这一系统调用的不同实现的比较。

System Call Overhead
测试进入和离开操作系统内核的代价,即一次系统调用的代价。它利用一个反复地调用 getpid 函数的小程序达到此目的。

Shell Scripts
测试一秒钟内一个进程可以并发地开始一个 shell 脚本的 n 个拷贝的次数,n 一般取值 1,2,4,8。(我在测试时取 1, 8)。这个脚本对一个数据文件进行一系列的变形操作(transformation)。

5 Run的详细用法

Run用法
     Run [ -q | -v ] [-i <n> ] [-c <n> [-c <n> ...]] [test ...]
选项说明:
-q 不显示测试过程
-v 显示测试过程
-i <count> 执行次数,最低3次,默认10
-c <n> 每次测试并行n个copies(并行任务)
备注:-c选项可以用来执行多次,如:  Run -c 1 -c 4表示执行两次,第一次单个copies,第二次4个copies的测试任务。
test:


 
 
  1. arithmetic Runs arithoh, short, int, long, float, double,
  2. and whetstone- double
  3. dhry Alias for dhry2reg
  4. dhrystone Alias for dhry2reg
  5. whets Alias for whetstone- double
  6. whetstone Alias for whetstone- double
  7. load Runs shell1, shell8, and shell16
  8. misc Runs C, dc, and hanoi
  9. speed Runs the arithmetic and system groups
  10. oldsystem Runs execl, fstime, fsbuffer, fsdisk, pipe, context1,
  11. spawn, and syscall
  12. system Runs oldsystem plus shell1, shell8, and shell16
  13. fs Runs fstime-w, fstime-r, fstime, fsbuffer-w,
  14. fsbuffer-r, fsbuffer, fsdisk-w, fsdisk-r, and fsdisk
  15. shell Runs shell1, shell8, and shell16
  16. index Runs the tests which constitute the official index:
  17. the oldsystem group, plus dhry2reg, whetstone- double,
  18. shell1, and shell8
  19. See "The BYTE Index" below for more information.
  20. graphics Runs the tests which constitute the graphics index:
  21. 2d-rects, 2d-ellipse, 2d-aashapes, 2d- text, 2d-blit,
  22. 2d-window, and ubgears
  23. gindex Runs the index and graphics groups, to generate both
  24. sets of index results
  25. all Runs all tests


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值