UnixBench算分介紹

   關於如何用UnixBench,介紹文章不少,這裏就不展開了。這裏重點描述下它是如何算分的。算法

運行參數

碰到不少客戶,裝好後,直接./Run,就把結果跑出來了,而後還只取最後一個分值,比誰高誰低。
下面列一下4C8G的結果:shell

------------------------------------------------------------------------
Benchmark Run: 一 6月 25 2018 20:25:47 - 20:54:19
4 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       30971628.9 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     3928.1 MWIPS (12.4 s, 7 samples)
Execl Throughput                               3117.6 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        645027.2 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          229505.4 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1288742.6 KBps  (30.0 s, 2 samples)
Pipe Throughput                             1635960.9 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 337333.8 lps   (10.0 s, 7 samples)
Process Creation                               8238.2 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   5817.0 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   2183.9 lpm   (60.0 s, 2 samples)
System Call Overhead                        2465754.7 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   30971628.9   2654.0
Double-Precision Whetstone                       55.0       3928.1    714.2
Execl Throughput                                 43.0       3117.6    725.0
File Copy 1024 bufsize 2000 maxblocks          3960.0     645027.2   1628.9
File Copy 256 bufsize 500 maxblocks            1655.0     229505.4   1386.7
File Copy 4096 bufsize 8000 maxblocks          5800.0    1288742.6   2222.0
Pipe Throughput                               12440.0    1635960.9   1315.1
Pipe-based Context Switching                   4000.0     337333.8    843.3
Process Creation                                126.0       8238.2    653.8
Shell Scripts (1 concurrent)                     42.4       5817.0   1371.9
Shell Scripts (8 concurrent)                      6.0       2183.9   3639.9
System Call Overhead                          15000.0    2465754.7   1643.8
                                                                   ========
System Benchmarks Index Score                                        1362.9

------------------------------------------------------------------------
Benchmark Run: 一 6月 25 2018 20:54:19 - 21:22:54
4 CPUs in system; running 4 parallel copies of tests

Dhrystone 2 using register variables      114984418.6 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                    16614.2 MWIPS (11.6 s, 7 samples)
Execl Throughput                              13645.3 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        751698.4 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          230211.7 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1964420.6 KBps  (30.0 s, 2 samples)
Pipe Throughput                             5999380.0 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                1095000.2 lps   (10.0 s, 7 samples)
Process Creation                              34454.9 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  18218.1 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   2493.1 lpm   (60.0 s, 2 samples)
System Call Overhead                        5643267.3 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0  114984418.6   9853.0
Double-Precision Whetstone                       55.0      16614.2   3020.8
Execl Throughput                                 43.0      13645.3   3173.3
File Copy 1024 bufsize 2000 maxblocks          3960.0     751698.4   1898.2
File Copy 256 bufsize 500 maxblocks            1655.0     230211.7   1391.0
File Copy 4096 bufsize 8000 maxblocks          5800.0    1964420.6   3386.9
Pipe Throughput                               12440.0    5999380.0   4822.7
Pipe-based Context Switching                   4000.0    1095000.2   2737.5
Process Creation                                126.0      34454.9   2734.5
Shell Scripts (1 concurrent)                     42.4      18218.1   4296.7
Shell Scripts (8 concurrent)                      6.0       2493.1   4155.1
System Call Overhead                          15000.0    5643267.3   3762.2
                                                                   ========
System Benchmarks Index Score                                        3357.0

不少人就拿了3357那個分數去比了,可是上面那個單進程結果1362.9也有意義,但凡接觸了這麼多案例,沒人關心過。多進程結果就是根據系統CPU核數,同時起多個進程的結果;單進程就是隻起一個進程的結果,對於系統性能來講,兩個結果都是有意義的。

話說回來,./Run 到底執行了什麼?默認執行的是Index模塊,它包含下面幾個小程序:小程序

"dhry2reg", "whetstone-double", "execl",
    "fstime", "fsbuffer", "fsdisk", "pipe", "context1", "spawn", "shell1", "shell8","syscall"

對應的就是上面的結果的各個結果對應的case了。
翻看了下它的源代碼,它的執行參數以下:./Run 模塊 -i 迭代次數 -c 進程併發數 -q/-v (輸出方式。centos

  • 模塊:有時候你只想測某一個小程序的結果,那你能夠修改本身去新增一個模塊,修改測試內容,這對於調試是很是方便的,也能夠直接指定某個執行程序。
  • 迭代次數:關於迭代次數,不能想固然的就理解成這就是要執行的次數了,默認框架分爲兩種迭代模式,一種是短迭代次數,默認 3次,一種是 長迭代次數,默認10 次。那輸入的迭代次數就是默認的長迭代次數,短迭代次數=(迭代次數+1)/3,若是結果小於就是1. 程序配置好了,該選擇哪一個迭代次數。
  • 進程併發數:若是你想進程併發數不是系統CPU數,那就能夠經過這個調整;
  • 輸出方式:是靜默仍是詳細輸出方式;

算分

每一個小程序在執行的時候都須要指定迭代模式和執行時間以及併發狀況,全部的進程一次執行的結果都是統一模式。併發

單進程算分:

下面是單進程的一個舉例:框架

Process Creation -- 1 copy
==> "/opt/unixbench/UnixBench/pgms/spawn" 30 2>&1 >> "/opt/unixbench/UnixBench/results/VM_0_13_centos-2018-06-25-05.log"

#### Pass 1


# COUNT0: 247371 #分數
# COUNT1: 1 # timebase 程序寫死
# COUNT2: lps # 測試項名稱
# elapsed: 30.003119 # 耗時
# pid: 16803 # 進程ID
# status: 0 # 是否成功退出

#### Pass 2


# COUNT0: 242919
# COUNT1: 1
# COUNT2: lps
# elapsed: 30.002898
# pid: 5035
# status: 0

#### Pass 3


# COUNT0: 243989
# COUNT1: 1
# COUNT2: lps
# elapsed: 30.002732
# pid: 21228
# status: 0

*Dump score:     242919.0
Count score:     243989.0
Count score:     247371.0

>>>> Results of 1 copy
>>>> score: 8188.34084738901
>>>> time: 30.0029255
>>>> iterations: 2

其中COUNT0,COUNT1,COUNT2是這麼算出來的,每一個進程的結果如:oop

COUNT|x|y|x

通過解析,變成以下:性能

COUNT0 = x
    COUNT1 = y
    COUNT2 = z

算分過程以下:測試

  1. 根據COUNT0從小到大,去掉 1/3 的最差結果;
  2. 若是timebase,耗時都是大於0, $product += log($COUNT0) - log(耗時/ $timebase) 不然就不須要考慮耗時這塊: $product += log($COUNT0) 
  3. 單項性能分:$score = exp($product/2),2是統計的迭代次數,通過計算剛好是這個分數,與系統輸出一致。
    它總的算法思想:就是先經過log降維,把不一樣次數不同的結果儘量拉平,平均而後在階乘,後面多個結果也是這個思想,先降維,再平均,再階乘。

多進程算分

那若是併發執行多個呢?舉例以下:spa

Shell Scripts (1 concurrent) -- 4 copies
==> "/opt/unixbench/UnixBench/pgms/looper" 60 "/opt/unixbench/UnixBench/pgms/multi.sh" 1 2>&1 >> "/opt/unixbench/UnixBench/results/VM_0_13_centos-2018-06-25-05.log"

#### Pass 1


# COUNT0: 4614
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.005639
# pid: 20858
# status: 0

# COUNT0: 4596
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.009496
# pid: 20859
# status: 0

# COUNT0: 4592
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.011761
# pid: 20862
# status: 0

# COUNT0: 4614
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.011930
# pid: 20864
# status: 0

#### Pass 2


# COUNT0: 4547
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.005597
# pid: 10791
# status: 0

# COUNT0: 4590
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.013270
# pid: 10793
# status: 0

# COUNT0: 4578
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.006054
# pid: 10794
# status: 0

# COUNT0: 4561
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.014214
# pid: 10797
# status: 0

#### Pass 3


# COUNT0: 4631
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.013816
# pid: 31734
# status: 0

# COUNT0: 4632
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.012614
# pid: 31735
# status: 0

# COUNT0: 4637
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.005633
# pid: 31737
# status: 0

# COUNT0: 4645
# COUNT1: 60
# COUNT2: lpm
# elapsed: 60.006082
# pid: 31740
# status: 0

*Dump score:      18276.0
Count score:      18416.0
Count score:      18545.0

>>>> Sum of 4 copies
>>>> score: 18477.4244713467
>>>> time: 60.009621375
>>>> iterations: 2

算分過程以下:

  1. 分數:如18545,就是PASS3個項的加總: 4631+4632+4637+4645
  2. 耗時:平均值,即:(60.013816+60.012614+60.005633+60.006082)/4=60.00953625
  3. timebase: 仍是那個COUNT1
    上述3步便是把一個併發結果合成一個結果,而後的積分方式跟單進程的方式同樣

總分

那文章開頭多進程的圖例分數舉例:

  1. 算出來的每項score有個加權分數,要除以10(做爲單項比拼,我以爲除不除10無所謂,估計是爲了跟總分接近)
  2. 總分計算:=exp(average(每項score分*10)),結果偏偏好就是咱們要的結果。

綜上對UnixBench的分數計算算是全面介紹了一邊,附件有excel證實計算過程。

原文連接

相關文章
相關標籤/搜索