UnixBench算分介绍

时间:2024-10-10 11:36:20

关于如何用UnixBench,介绍文章很多,这里就不展开了。这里重点描述下它是如何算分的。

运行参数

碰到很多客户,装好后,直接./Run,就把结果跑出来了,然后还只取最后一个分值,比谁高谁低。
下面列一下4C8G的结果:

------------------------------------------------------------------------
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 (输出方式。

  • 模块:有时候你只想测某一个小程序的结果,那你可以修改自己去新增一个模块,修改测试内容,这对于调试是非常方便的,也可以直接指定某个执行程序。
  • 迭代次数:关于迭代次数,不能想当然的就理解成这就是要执行的次数了,默认框架分为两种迭代模式,一种是短迭代次数,默认 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是这么算出来的,每个进程的结果如:

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降维,把不同次数不一样的结果尽可能拉平,平均然后在阶乘,后面多个结果也是这个思想,先降维,再平均,再阶乘。

多进程算分

那如果并发执行多个呢?举例如下:

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证明计算过程。

附件下载: 算分过程.xls...[米拉齐].1543830848.zip

阅读原文​​​​​​​

更多技术干货 请关注阿里云云栖社区微信号 :yunqiinsight