Linux测试CPU 整型算力和浮点数算力

jupiter
2021-11-30 / 0 评论 / 2,039 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年12月07日,已超过1064天没有更新,若内容或图片失效,请留言反馈。

Linux测试CPU 整型算力和浮点数算力

1.sysbench:用于测试 CPU 整型算力

1.0 介绍

SysBench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。它主要包括以下几种方式的测试:

  1. cpu性能
  2. 磁盘io性能
  3. 调度程序性能
  4. 内存分配及传输速度
  5. POSIX线程性能
  6. 数据库性能(OLTP基准测试)

目前sysbench主要支持 MySQL,pgsql,Oracle 这3种数据库。

1.1 安装依赖

# 安装依赖-centerOS
sudo yum install automake libtool gcc -y
# 安装依赖-ubuntu
sudo apt install automake libtool gcc -y

1.2 下载并编译安装

# 下载sysbench源码包
wget https://github.com/akopytov/sysbench/archive/1.0.20.tar.gz -O sysbench-1.0.20.tar.gz
# 解压
tar -xvf sysbench-1.0.20.tar.gz
# 执行autogen.sh
cd sysbench-1.0.20
sh autogen.sh
# 生成Makefile
./configure --without-mysql
# 编译并安装
sudo make && sudo make install
# 查看安装结果(版本信息)
sysbench --version

1.3 调用测试

  • 测试 4 线程,20000 内的质数计算能力
(base) jupiter@dell:/software/sysbench-1.0.20$ sysbench cpu --cpu-max-prime=20000  --threads=4 --time=60 run

# 参数解释
--cpu-max-prime=20000 测试计算素数直到某个最大值(20000)所需要的时间
--threads=4 使用线程数为4
--time=60 重复次数为60次
  • 测试结果/Score : 1497.06
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 4
Initializing random number generator from current time


Prime numbers limit: 20000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:  1497.06

General statistics:
    total time:                          60.0026s
    total number of events:              89830

Latency (ms):
         min:                                    2.52
         avg:                                    2.67
         max:                                   22.63
         95th percentile:                        2.76
         sum:                               239972.33

Threads fairness:
    events (avg/stddev):           22457.5000/42.39
    execution time (avg/stddev):   59.9931/0.00

2.sysbench:用于测试 CPU 浮点型算力

2.1 安装依赖

# 安装依赖-centerOS
sudo yum install automake libtool gcc -y
# 安装依赖-ubuntu
sudo apt install automake libtool gcc -y

2.2 下载并编译安装

# 下载
wget http://soft.vpser.net/test/unixbench/unixbench-5.1.2.tar.gz
# 解压
tar zxvf unixbench-5.1.2.tar.gz
# 配置如果不需要进行图形测试或者不在图形化界面下测试,则将Makefile文件中GRAPHIC_TEST = defined注释掉
cd unixbench-5.1.2
make
# 安装依赖
sudo apt install -y perl
# 执行测试
./Run

2.3 测试结果说明

测试项目项目说明
Dhrystone 2 using register variables测试 string handling
Double-Precision Whetstone测试浮点数操作的速度和效率
Execl Throughput此测试考察每秒钟可以执行的execI系统调用的次数
File Copy 1024 bufsize 2000 maxblocks测试从一个文件向另外一个文件传输数据的速率。
File Copy 256 bufsize 500 maxblocks测试从一个文件向另外一个文件传输数据的速率。
File Read 4096 bufsize 8000 maxblocks测试从一个文件向另外一个文件传输数据的速率。
Pipe-based Context Switching测试两个进程(每秒钟)通过一个管道交换一个不断增 长的整数的次数。
Pipe Throughput一秒钟内一个进程可以向一个管道写512字节数据然后 再读回的次数
Process Creation测试每秒钟一个进程可以创建子进程然后收回子进程的 次数(子进程一定立即退出)。
Shell Scripts (8 concurrent)测试一秒钟内一个进程可以并发地开始一个shell脚本 的n个拷贝的次数,n一般取值1,2,4,8.
System Call Overhead测试进入和离开操作系统内核的代价,即一次系统调用 的代价。

2.4 测试结果

  • 简略摘要
# 单核双精度浮点算力
Double-Precision Whetstone                     5476.7 MWIPS

# 4核双精度浮点算力
Double-Precision Whetstone                    21621.7 MWIPS
  • 详细信息
========================================================================
   BYTE UNIX Benchmarks (Version 5.1.2)

   System: dell: GNU/Linux
   OS: GNU/Linux -- 5.11.0-40-generic -- #44~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz (4599.9 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 1: Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz (4599.9 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 2: Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz (4599.9 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 3: Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz (4599.9 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   19:40:36 up 11 days,  9:27,  3 users,  load average: 0.18, 0.34, 0.47; runlevel 5

------------------------------------------------------------------------
Benchmark Run: 一 11月 29 2021 19:40:36 - 20:08:45
4 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       35459584.6 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     5476.7 MWIPS (9.9 s, 7 samples)
Execl Throughput                               3206.9 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        527819.0 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          137340.3 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1512668.7 KBps  (30.0 s, 2 samples)
Pipe Throughput                              710906.8 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 151493.2 lps   (10.0 s, 7 samples)
Process Creation                               6097.0 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   6869.6 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   2230.7 lpm   (60.0 s, 2 samples)
System Call Overhead                         400377.9 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   35459584.6   3038.5
Double-Precision Whetstone                       55.0       5476.7    995.8
Execl Throughput                                 43.0       3206.9    745.8
File Copy 1024 bufsize 2000 maxblocks          3960.0     527819.0   1332.9
File Copy 256 bufsize 500 maxblocks            1655.0     137340.3    829.9
File Copy 4096 bufsize 8000 maxblocks          5800.0    1512668.7   2608.0
Pipe Throughput                               12440.0     710906.8    571.5
Pipe-based Context Switching                   4000.0     151493.2    378.7
Process Creation                                126.0       6097.0    483.9
Shell Scripts (1 concurrent)                     42.4       6869.6   1620.2
Shell Scripts (8 concurrent)                      6.0       2230.7   3717.8
System Call Overhead                          15000.0     400377.9    266.9
                                                                   ========
System Benchmarks Index Score                                        1007.7

------------------------------------------------------------------------
Benchmark Run: 一 11月 29 2021 20:08:45 - 20:36:59
4 CPUs in system; running 4 parallel copies of tests

Dhrystone 2 using register variables      136159740.8 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                    21621.7 MWIPS (9.9 s, 7 samples)
Execl Throughput                              10934.3 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1144908.0 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          300291.5 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       3433079.5 KBps  (30.0 s, 2 samples)
Pipe Throughput                             2704214.4 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 565815.4 lps   (10.0 s, 7 samples)
Process Creation                              31990.1 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  17826.7 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   2525.2 lpm   (60.1 s, 2 samples)
System Call Overhead                        1474932.5 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0  136159740.8  11667.5
Double-Precision Whetstone                       55.0      21621.7   3931.2
Execl Throughput                                 43.0      10934.3   2542.9
File Copy 1024 bufsize 2000 maxblocks          3960.0    1144908.0   2891.2
File Copy 256 bufsize 500 maxblocks            1655.0     300291.5   1814.5
File Copy 4096 bufsize 8000 maxblocks          5800.0    3433079.5   5919.1
Pipe Throughput                               12440.0    2704214.4   2173.8
Pipe-based Context Switching                   4000.0     565815.4   1414.5
Process Creation                                126.0      31990.1   2538.9
Shell Scripts (1 concurrent)                     42.4      17826.7   4204.4
Shell Scripts (8 concurrent)                      6.0       2525.2   4208.6
System Call Overhead                          15000.0    1474932.5    983.3
                                                                   ========
System Benchmarks Index Score                                        2980.8

参考资料

  1. sysbench压力测试工具安装和参数介绍
  2. UnixBench 测试工具简单使用
  3. ARM和X86云服务器的算力对比
0

评论 (0)

打卡
取消