1. 程式人生 > >Linux效能測試UnixBench一鍵指令碼

Linux效能測試UnixBench一鍵指令碼

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核心數量,運算時間不等)得出分數,越高越好。

測試方法:

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

測試專案:
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)。

下面是我的一個512MB,2核,OpenVZ的VPS的跑分結果:

   BYTE UNIX Benchmarks (Version 5.1.3)

   System: vpn: GNU/Linux
   OS: GNU/Linux -- 2.6.32-042stab076.8 -- #1 SMP Tue May 14 20:38:14 MSK 2013
   Machine: i686 (i386)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4533.6 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 1: Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4533.6 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   09:41:17 up 31 days,  9:21,  1 user,  load average: 0.23, 0.05, 0.02; runlevel 3

------------------------------------------------------------------------
Benchmark Run: Mon Jul 29 2013 09:41:17 - 10:09:29
2 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       17172222.3 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     2600.2 MWIPS (10.0 s, 7 samples)
Execl Throughput                               4152.8 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        622759.5 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          172634.3 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1218236.9 KBps  (30.0 s, 2 samples)
Pipe Throughput                             1416230.5 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 206509.4 lps   (10.0 s, 7 samples)
Process Creation                               8568.6 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   3145.9 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    528.3 lpm   (60.0 s, 2 samples)
System Call Overhead                        1528474.7 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   17172222.3   1471.5
Double-Precision Whetstone                       55.0       2600.2    472.8
Execl Throughput                                 43.0       4152.8    965.8
File Copy 1024 bufsize 2000 maxblocks          3960.0     622759.5   1572.6
File Copy 256 bufsize 500 maxblocks            1655.0     172634.3   1043.1
File Copy 4096 bufsize 8000 maxblocks          5800.0    1218236.9   2100.4
Pipe Throughput                               12440.0    1416230.5   1138.4
Pipe-based Context Switching                   4000.0     206509.4    516.3
Process Creation                                126.0       8568.6    680.0
Shell Scripts (1 concurrent)                     42.4       3145.9    742.0
Shell Scripts (8 concurrent)                      6.0        528.3    880.5
System Call Overhead                          15000.0    1528474.7   1019.0
                                                                   ========
System Benchmarks Index Score                                         960.4

------------------------------------------------------------------------
Benchmark Run: Mon Jul 29 2013 10:09:29 - 10:39:56
2 CPUs in system; running 2 parallel copies of tests

Dhrystone 2 using register variables       16851634.7 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     5182.9 MWIPS (10.0 s, 7 samples)
Execl Throughput                               4101.9 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        635244.9 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          174430.2 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1219982.0 KBps  (30.0 s, 2 samples)
Pipe Throughput                             1387297.9 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 196296.1 lps   (10.0 s, 7 samples)
Process Creation                              10889.9 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   4073.7 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    550.5 lpm   (60.2 s, 2 samples)
System Call Overhead                        1538517.4 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   16851634.7   1444.0
Double-Precision Whetstone                       55.0       5182.9    942.3
Execl Throughput                                 43.0       4101.9    953.9
File Copy 1024 bufsize 2000 maxblocks          3960.0     635244.9   1604.2
File Copy 256 bufsize 500 maxblocks            1655.0     174430.2   1054.0
File Copy 4096 bufsize 8000 maxblocks          5800.0    1219982.0   2103.4
Pipe Throughput                               12440.0    1387297.9   1115.2
Pipe-based Context Switching                   4000.0     196296.1    490.7
Process Creation                                126.0      10889.9    864.3
Shell Scripts (1 concurrent)                     42.4       4073.7    960.8
Shell Scripts (8 concurrent)                      6.0        550.5    917.5
System Call Overhead                          15000.0    1538517.4   1025.7
                                                                   ========
System Benchmarks Index Score                                        1058.3