使用 UnixBench 进行 Ubuntu 系统基准测试

通常,在我们需要采购新设备、或者准备升级设备的时候,总是希望对设备进行一系列的性能评估,除了直接看硬件参数,比较理性、简单的方法就是能有一个测试软件来为我们的硬件系统平台打个分,然后我们就可以根据这个数量化的结果来进行决策。这种方式对于个人或者一些小团队而言,更显得方便而又重要,因为个人和小团队都不太可能找设备供应商拿到足够的售前支持,或者去做专业的评估,而这种“跑个分”的方式不失为是一种既省成本又有效的办法。

恰好,最近刚完成了工作室里的服务器维护,其中有一台老旧的 Dell R410 重装了新系统,刚配置好环境,可以用来演示一下 UnixBench 的使用方法。

UnixBench 的安装

我第一次接触 UnixBench 的时候,并不知道有一键安装脚本,当时的教程是需要下载源码包,然后需要自己修改配置文件然后编译,受限于当时的能力水平,没有顺利编译完成,后来由于这个事情不太紧急,就不了了之了。最近偶然看到一篇文章,里面讲解了如何使用一件安装脚本,尝试了一下,方法的确比较简单,几乎不用什么操作就可以完成,以下将介绍以下该方法。

# 下载一键安装脚本
wget http://teddysun.com/wp-content/uploads/unixbench.sh
# 为脚本添加执行权限
chmod +x unixbench.sh
# 运行脚本 脚本运行会先检查依赖,会自动完成安装,这里需要 root 权限
sudo bash ./unixbench.sh

完成上述步骤,基准测试将自动开始。

测试

测试开始后,软件会自动进行各项测试,并为其评分,测试完成后,将会输出一个测试报表结果,以我的 Dell R410,配置为 E5507 16G内存,146G SAS Raid 0为例,结果如下:

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: WosDevServer: GNU/Linux
   OS: GNU/Linux -- 4.4.0-119-generic -- #143-Ubuntu SMP Mon Apr 2 16:08:24 UTC 2018
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Xeon(R) CPU E5507 @ 2.27GHz (4522.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 1: Intel(R) Xeon(R) CPU E5507 @ 2.27GHz (4521.8 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 2: Intel(R) Xeon(R) CPU E5507 @ 2.27GHz (4522.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 3: Intel(R) Xeon(R) CPU E5507 @ 2.27GHz (4521.8 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 4: Intel(R) Xeon(R) CPU E5507 @ 2.27GHz (4522.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 5: Intel(R) Xeon(R) CPU E5507 @ 2.27GHz (4521.8 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 6: Intel(R) Xeon(R) CPU E5507 @ 2.27GHz (4522.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 7: Intel(R) Xeon(R) CPU E5507 @ 2.27GHz (4521.8 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   09:42:18 up 16:37,  1 user,  load average: 0.58, 0.14, 0.05; runlevel 5

------------------------------------------------------------------------
Benchmark Run: Wed Apr 18 2018 09:42:18 - 10:10:35
8 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       22890258.0 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     2974.5 MWIPS (9.9 s, 7 samples)
Execl Throughput                               2009.3 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        356519.6 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks           99637.7 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks        962479.7 KBps  (30.0 s, 2 samples)
Pipe Throughput                              511868.4 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 123716.9 lps   (10.0 s, 7 samples)
Process Creation                               3374.2 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   6240.7 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   3324.5 lpm   (60.0 s, 2 samples)
System Call Overhead                         509821.0 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   22890258.0   1961.5
Double-Precision Whetstone                       55.0       2974.5    540.8
Execl Throughput                                 43.0       2009.3    467.3
File Copy 1024 bufsize 2000 maxblocks          3960.0     356519.6    900.3
File Copy 256 bufsize 500 maxblocks            1655.0      99637.7    602.0
File Copy 4096 bufsize 8000 maxblocks          5800.0     962479.7   1659.4
Pipe Throughput                               12440.0     511868.4    411.5
Pipe-based Context Switching                   4000.0     123716.9    309.3
Process Creation                                126.0       3374.2    267.8
Shell Scripts (1 concurrent)                     42.4       6240.7   1471.9
Shell Scripts (8 concurrent)                      6.0       3324.5   5540.8
System Call Overhead                          15000.0     509821.0    339.9
                                                                   ========
System Benchmarks Index Score                                         768.0

------------------------------------------------------------------------
Benchmark Run: Wed Apr 18 2018 10:10:35 - 10:38:54
8 CPUs in system; running 8 parallel copies of tests

Dhrystone 2 using register variables      181646934.4 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                    23770.7 MWIPS (9.9 s, 7 samples)
Execl Throughput                              17323.7 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        622988.4 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          167131.8 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1762630.6 KBps  (30.0 s, 2 samples)
Pipe Throughput                             4066846.5 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                1014461.5 lps   (10.0 s, 7 samples)
Process Creation                              43249.7 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  40928.1 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   5324.5 lpm   (60.0 s, 2 samples)
System Call Overhead                        3115517.6 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0  181646934.4  15565.3
Double-Precision Whetstone                       55.0      23770.7   4322.0
Execl Throughput                                 43.0      17323.7   4028.8
File Copy 1024 bufsize 2000 maxblocks          3960.0     622988.4   1573.2
File Copy 256 bufsize 500 maxblocks            1655.0     167131.8   1009.9
File Copy 4096 bufsize 8000 maxblocks          5800.0    1762630.6   3039.0
Pipe Throughput                               12440.0    4066846.5   3269.2
Pipe-based Context Switching                   4000.0    1014461.5   2536.2
Process Creation                                126.0      43249.7   3432.5
Shell Scripts (1 concurrent)                     42.4      40928.1   9652.9
Shell Scripts (8 concurrent)                      6.0       5324.5   8874.1
System Call Overhead                          15000.0    3115517.6   2077.0
                                                                   ========
System Benchmarks Index Score                                        3702.0



======= Script description and score comparison completed! =======

为了进行对比,我同时也在我的开发机上运行了一个虚拟机进行测试,虚拟机设置了单核 CPU,2G 内存,测试结果如下:

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: ubuntu: GNU/Linux
   OS: GNU/Linux -- 4.4.0-119-generic -- #143-Ubuntu SMP Mon Apr 2 16:08:24 UTC 2018
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (6411.1 bogomips)
          x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   10:45:37 up 2 min,  1 user,  load average: 0.22, 0.07, 0.02; runlevel 5

------------------------------------------------------------------------
Benchmark Run: Wed Apr 18 2018 10:45:37 - 11:13:49
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       40453839.7 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     2933.5 MWIPS (9.9 s, 7 samples)
Execl Throughput                               5999.9 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        818195.6 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          246488.8 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1618077.0 KBps  (30.0 s, 2 samples)
Pipe Throughput                             1298128.5 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 218737.5 lps   (10.0 s, 7 samples)
Process Creation                              15710.1 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  10794.3 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   1405.5 lpm   (60.0 s, 2 samples)
System Call Overhead                        1217286.8 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   40453839.7   3466.5
Double-Precision Whetstone                       55.0       2933.5    533.4
Execl Throughput                                 43.0       5999.9   1395.3
File Copy 1024 bufsize 2000 maxblocks          3960.0     818195.6   2066.2
File Copy 256 bufsize 500 maxblocks            1655.0     246488.8   1489.4
File Copy 4096 bufsize 8000 maxblocks          5800.0    1618077.0   2789.8
Pipe Throughput                               12440.0    1298128.5   1043.5
Pipe-based Context Switching                   4000.0     218737.5    546.8
Process Creation                                126.0      15710.1   1246.8
Shell Scripts (1 concurrent)                     42.4      10794.3   2545.8
Shell Scripts (8 concurrent)                      6.0       1405.5   2342.5
System Call Overhead                          15000.0    1217286.8    811.5
                                                                   ========
System Benchmarks Index Score                                        1435.0



======= Script description and score comparison completed! =======

由于虚拟机仅配置了单核 CPU,因此这里只有 1 parallel 单线程测试,并没有上面服务器中的多线程测试。我们可以从两份结果对比得出,由于不同世代的 CPU 技术差异,这里的 I5-4570 的单核表现与 XEON-E5507相比几乎是性能翻倍。

评估

以上的测试给出的分数,我们可以作为评估的依据,但实际决策中,还需要考虑其他的情况。如服务器的安放、稳定性以及一起其他的功能,比如 Dell 的服务器支持 iDrac 远程控制,可以通过网络控制服务器开关、重启以及监控设备运行情况等。如果单从运算性能看,可能会组装一台 i5 的电脑性能更好,但如遇停电、或者死机的情况,没有远程控制维护服务器,那么就需要考虑其他的处理方案。

小结

本篇文章介绍了如何安装及使用 UnixBench,以及简单介绍了如何以一种比较低成本的方式来评估设备情况,希望能对大家有所帮助。

参考资料

《基于Linux系统的性能测试》
《Linux性能测试工具-UnixBench--安装以及结果分析》

你可能感兴趣的:(使用 UnixBench 进行 Ubuntu 系统基准测试)