1 概述
服务器的基准测试,常见的测试工具有UnixBench、Geekbench、sysbench等。本文主要介绍UnixBench和Geekbench。
1.1 UnixBench
UnixBench是一款开源的测试UNIX系统基本性能的工具(https://github.com/kdlucas/byte-unixbench),是比较通用的测试云服务器性能的工具。UnixBench会执行一系列的测试,测试系统各个方面的性能,然后将每个测试结果和一个基准值进行比较得到一个索引值,所有测试项目的索引值结合在一起最终形成一个[ 分数值 ]。
UnixBench包含多个独立测试,以下是每个测试的功能概述:
Dhrystone
Reinhold Weicker于1984年开发。这个基准用于测量和比较计算机的性能。测试专注于字符串处理,因为没有浮点运算。它受硬件和软件设计、编译器和链接器选项、代码优化、缓存内存、等待状态以及整数数据类型的影响很大。
Whetstone
此测试衡量浮点运算的速度和效率。该测试包含几个模块,旨在代表科学应用程序中通常执行的各种操作。广泛使用了C函数,如sin、cos、sqrt、exp和log,以及整数和浮点数学运算、数组访问、条件分支和过程调用。此测试测量整数和浮点算术。
execl 吞吐量
此测试测量每秒可以执行多少次execl调用。execl是exec家族的一部分,用于用新进程映像替换当前进程图像。它是execve()函数的许多类似命令的前端。
文件复制
这衡量以各种缓冲区大小将数据从一个文件传输到另一个文件的速度。文件读写和复制测试记录在指定时间内(默认为10秒)可以写入、读取和复制的字符数量。
管道吞吐量
管道是最简单的进程间通信形式。管道吞吐量是指一个进程每秒能向管道写入512字节并读回多少次。管道吞吐量测试在实际编程中没有直接对应物。
管道为基础的上下文切换
这个测试测量两个进程通过管道交换递增整数的次数。基于管道的上下文切换测试更接近现实世界的应用。测试程序会生成一个子进程,与其进行双向管道对话。
进程创建
此测试测量一个进程能够叉出并收养立即退出的子进程的次数。进程创建涉及创建新的进程控制块和内存分配,因此直接关系到内存带宽。通常,此基准用于比较操作系统进程创建调用的不同实现。
脚本语言
shell脚本测试测量每分钟一个进程可以启动并收养一组并发的shell脚本副本的数量,这些脚本对数据文件应用一系列转换。
系统调用开销
这估计进入和离开操作系统内核的成本,即执行系统调用的开销。它由一个简单程序组成,该程序反复调用getpid(返回调用进程的ID)系统调用。执行此类调用所需的时间用于估算进出内核的成本。
图形测试
提供了2D和3D图形测试;目前,3D套件尤为有限,主要包括ubgears程序。这些测试旨在大致了解系统的2D和3D图形性能。当然,需要注意的是,报告的性能不仅取决于硬件,还取决于系统是否拥有适当的驱动程序。
1.2 Geekbench
Geekbench是一款跨平台的处理器、内存等基准测试程序,可用于评估各种设备(包括智能手机、平板电脑、笔记本电脑和台式电脑)的性能。它通过运行一系列模拟真实使用场景的工作负载来衡量设备的 CPU、内存和计算能力。Geekbench 提供单核和多核评分,以及综合评分。Geekbench的评分系统旨在反映设备在日常任务中的实际性能。例如,单核评分可用于评估设备在网页浏览、电子邮件和文档编辑等任务中的性能,而多核评分则可用于评估设备在视频编辑、照片编辑和游戏等任务中的性能。
2 环境
一台centos 7.9的服务器。
3 UnixBench跑分
3.1 UnixBench部署
mkdir -p /opt/third-party
cd /opt/third-party
yum install git -y
git clone https://github.com/kdlucas/byte-unixbench.git
cd byte-unixbench/UnixBench
make
3.2 UnixBench跑分
进入主目录,运行名称叫做Run的工具即可。
3.2.1 单核跑分
./Run -c 1
3.2.2 多核跑分
跑分过程会持续几十分钟,请耐心等待。
cores=$( cat /proc/cpuinfo| grep "processor"| wc -l )
echo $cores
./Run -c $cores
结果如下:
make all
make[1]: Entering directory '/opt/third-party/byte-unixbench-master/UnixBench'
make distr
make[2]: Entering directory '/opt/third-party/byte-unixbench-master/UnixBench'
Checking distribution of files
./pgms exists
./src exists
./testdir exists
./tmp exists
./results exists
make[2]: Leaving directory '/opt/third-party/byte-unixbench-master/UnixBench'
make programs
make[2]: Entering directory '/opt/third-party/byte-unixbench-master/UnixBench'
make[2]: Nothing to be done for 'programs'.
make[2]: Leaving directory '/opt/third-party/byte-unixbench-master/UnixBench'
make[1]: Leaving directory '/opt/third-party/byte-unixbench-master/UnixBench'
sh: 3dinfo: command not found
# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #
Version 5.1.6 Change getpid method to syscall
Multi-CPU version Version 5 revisions by Ian Smith,
Sunnyvale, CA, USA
January 13, 2011 johantheghost at yahoo period com
------------------------------------------------------------------------------
Use directories for:
* File I/O tests (named fs***) = /opt/third-party/byte-unixbench-master/UnixBench/tmp
* Results = /opt/third-party/byte-unixbench-master/UnixBench/results
------------------------------------------------------------------------------
12 x Dhrystone 2 using register variables 1 2 3 4 5 6 7 8 9 10
12 x Double-Precision Whetstone 1 2 3 4 5 6 7 8 9 10
12 x Execl Throughput 1 2 3
12 x File Copy 1024 bufsize 2000 maxblocks 1 2 3
12 x File Copy 256 bufsize 500 maxblocks 1 2 3
12 x File Copy 4096 bufsize 8000 maxblocks 1 2 3
12 x Pipe Throughput 1 2 3 4 5 6 7 8 9 10
12 x Pipe-based Context Switching 1 2 3 4 5 6 7 8 9 10
12 x Process Creation 1 2 3
12 x System Call Overhead 1 2 3 4 5 6 7 8 9 10
12 x Shell Scripts (1 concurrent) 1 2 3
12 x Shell Scripts (8 concurrent) 1 2 3
========================================================================
BYTE UNIX Benchmarks (Version 5.1.6)
System: master.lj.io: GNU/Linux
OS: GNU/Linux -- 3.10.0-957.21.3.el7.x86_64 -- #1 SMP Tue Jun 18 16:35:19 UTC 2019
Machine: x86_64 (x86_64)
Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
CPU 0: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 1: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 2: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 3: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 4: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 5: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 6: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 7: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 8: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 9: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 10: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 11: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz (4786.7 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
20:16:52 up 27 min, 2 users, load average: 0.01, 0.14, 0.12; runlevel 2024-11-10
------------------------------------------------------------------------
Benchmark Run: Sun Nov 10 2024 20:16:52 - 20:45:16
12 CPUs in system; running 12 parallel copies of tests
Dhrystone 2 using register variables 156474593.4 lps (10.0 s, 7 samples)
Double-Precision Whetstone 34037.0 MWIPS (10.1 s, 7 samples)
Execl Throughput 8119.7 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 186220.9 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 48979.2 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 508057.4 KBps (30.0 s, 2 samples)
Pipe Throughput 1346597.0 lps (10.0 s, 7 samples)
Pipe-based Context Switching 81650.6 lps (10.0 s, 7 samples)
Process Creation 21601.8 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 14651.1 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 1935.8 lpm (60.1 s, 2 samples)
System Call Overhead 1221110.8 lps (10.0 s, 7 samples)
System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 156474593.4 13408.3
Double-Precision Whetstone 55.0 34037.0 6188.5
Execl Throughput 43.0 8119.7 1888.3
File Copy 1024 bufsize 2000 maxblocks 3960.0 186220.9 470.3
File Copy 256 bufsize 500 maxblocks 1655.0 48979.2 295.9
File Copy 4096 bufsize 8000 maxblocks 5800.0 508057.4 876.0
Pipe Throughput 12440.0 1346597.0 1082.5
Pipe-based Context Switching 4000.0 81650.6 204.1
Process Creation 126.0 21601.8 1714.4
Shell Scripts (1 concurrent) 42.4 14651.1 3455.5
Shell Scripts (8 concurrent) 6.0 1935.8 3226.3
System Call Overhead 15000.0 1221110.8 814.1
========
System Benchmarks Index Score 1417.3
从输出报告看,最终的分数是:1417.3。
4 Geekbench跑分
4.1 Geekbench部署
mkdir -p /opt/third-party
cd /opt/third-party
yum install wget -y
wget https://cdn.geekbench.com/Geekbench-5.4.3-Linux.tar.gz
tar xf Geekbench-5.4.3-Linux.tar.gz
文件解压完成后,主目录会存在一个叫geekbench5的工具,执行它即可进行跑分。
4.2 Geekbench跑分
跑分过程会持续几十分钟,请耐心等待。
./geekbench5
跑分测试结果会自动上传到Geekbench数据库,输出日志中会打印网址,在浏览器打开该网址即可查看结果。
Geekbench 5.4.3 Tryout : https://www.geekbench.com/
Geekbench 5 requires an active Internet connection when in tryout mode and
automatically uploads benchmark results to the Geekbench Browser.
Buy a Geekbench 5 license from the Primate Labs Store to enable offline use
and unlock other features:
https://store.primatelabs.com/v5
Enter your Geekbench 5 license using the following command line:
./geekbench5 --unlock <email> <key>
Running Gathering system information
System Information
Operating System CentOS Linux 7 (Core)
Kernel Linux 3.10.0-957.21.3.el7.x86_64 x86_64
Model VMware, Inc. VMware Virtual Platform
Motherboard Intel Corporation 440BX Desktop Reference Platform
BIOS Phoenix Technologies LTD 6.00
Processor Information
Name Intel Xeon E5645
Topology 4 Processors, 12 Cores
Identifier GenuineIntel Family 6 Model 44 Stepping 2
Base Frequency 2.39 GHz
L1 Instruction Cache 32.0 KB x 3
L1 Data Cache 32.0 KB x 3
L2 Cache 256 KB x 3
L3 Cache 12.0 MB
Memory Information
Size 12.7 GB
Single-Core
Running AES-XTS
Running Text Compression
Running Image Compression
Running Navigation
Running HTML5
Running SQLite
Running PDF Rendering
Running Text Rendering
Running Clang
Running Camera
Running N-Body Physics
Running Rigid Body Physics
Running Gaussian Blur
Running Face Detection
Running Horizon Detection
Running Image Inpainting
Running HDR
Running Ray Tracing
Running Structure from Motion
Running Speech Recognition
Running Machine Learning
Multi-Core
Running AES-XTS
Running Text Compression
Running Image Compression
Running Navigation
Running HTML5
Running SQLite
Running PDF Rendering
Running Text Rendering
Running Clang
Running Camera
Running N-Body Physics
Running Rigid Body Physics
Running Gaussian Blur
Running Face Detection
Running Horizon Detection
Running Image Inpainting
Running HDR
Running Ray Tracing
Running Structure from Motion
Running Speech Recognition
Running Machine Learning
Uploading results to the Geekbench Browser. This could take a minute or two
depending on the speed of your internet connection.
Upload succeeded. Visit the following link and view your results online:
https://browser.geekbench.com/v5/cpu/23045353
Visit the following link and add this result to your profile:
https://browser.geekbench.com/v5/cpu/23045353/claim?key=250861
5 小结
本文介绍了UnixBench和Geekbench这两款服务器压测跑分工具,通过下载、编译和实操来详细体验服务器跑分的过程。