ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Linux CPU 性能测试

2022-04-27 23:34:57  阅读:257  来源: 互联网

标签:Linux CPU threads 测试 time MIPS cpu 7z


sysbench

Sysbench is mainly intended for doing database benchmarking. However it includes options to test CPU, memory and file throughput as well.

安装

sudo apt install sysbench

使用

ubuntu@instance:~$ sysbench cpu --threads=3 run
sysbench 1.0.18 (using system LuaJIT 2.1.0-beta3)

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


Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:
    events per second: 10519.03

General statistics:
    total time:                          10.0003s
    total number of events:              105208

Latency (ms):
         min:                                    0.28
         avg:                                    0.28
         max:                                    5.22
         95th percentile:                        0.29
         sum:                                29976.02

Threads fairness:
    events (avg/stddev):           35069.3333/81.99
    execution time (avg/stddev):   9.9920/0.00

events per second,值越大,性能越强。

上面是一个Oracle主机的测试结果,3个OCPU,每秒事件10519。单个OCPU每秒事件数为3484。i7-7700 CPU,单核每秒事件数1438,8核每秒事件数8469。可见Oracle主机的OCPU性能很强,单核性能是 i7-7700 的2.4倍。

7z

7z是个压缩/解压工具,压缩/解压天然吃CPU,用来测试性能顺理成章。而且官方还给出了一些CPU型号的测试结果排名:7-Zip LZMA Benchmark (7-cpu.com)

安装

sudo apt install p7zip-full

使用

语法:

7z b [number_of_iterations] [-mmt{N}] [-md{N}] [-mm={Method}]
  • number_of_iterations 迭代次数,测试多少轮,可用于检查内存错误
  • mmt 线程数

举例:

# 单线程
$ 7z b -mmt1
# 多线程
$ 7z b

结果说明:

ubuntu@instance:~$ 7z b

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=C.UTF-8,Utf16=on,HugeFiles=on,64 bits,3 CPUs LE)

LE
CPU Freq: - - - - - - 512000000 - -

RAM size:   17954 MB,  # CPU hardware threads:   3
RAM usage:    441 MB,  # Benchmark threads:      3

                       Compressing  |                  Decompressing
Dict     Speed Usage    R/U Rating  |      Speed Usage    R/U Rating
         KiB/s     %   MIPS   MIPS  |      KiB/s     %   MIPS   MIPS

22:       8642   175   4813   8407  |      98748   199   4227   8431
23:       8612   187   4695   8775  |      97477   200   4228   8438
24:       8438   196   4622   9073  |      95682   200   4201   8400
25:       8151   198   4694   9307  |      93742   200   4176   8344
----------------------------------  | ------------------------------
Avr:             189   4706   8891  |              200   4208   8403
Tot:             194   4457   8647

上面是Orace OCPU的测试结果,单核4706。i7-7700单核3768。

  • Dict:字典大小,22表示2^21=4MB
  • Usage:cpu总利用率。我有3个核,这里最多只用到200%,这是因为7z似乎只能使用2N个核(来源“When you specify (N*2) threads for test, the program creates N copies of LZMA encoder, and each LZMA encoder instance compresses separated block of test data.”——7-Zip LZMA Benchmark (7-cpu.com)
  • MIPS:million instructions per second
  • R/U MIPS:单核性能。
  • Rating MIPS:约等于Usage * (R/U MIPS)

更多介绍,查看帮助文档。man 7z,在最下面会看到:

HTML Documentation
/usr/share/doc/p7zip-full/DOC/MANUAL/start.htm

用vim或者浏览器打开此页面进入帮助文档主页。或直接打开以下页面查看benchmark相关内容:

chrome /usr/share/doc/p7zip/DOC/MANUAL/cmdline/commands/bench.htm

数值运算

比如写个python脚本:

import math
import time

t0 = time.time()
for i in range(0, 10000000):
    math.pow(47,39)
print(time.time() - t0)

将该脚本在不同的CPU上执行,通过对比运行时间,估计待测CPU的性能。


本文同步发布于:

标签:Linux,CPU,threads,测试,time,MIPS,cpu,7z
来源: https://www.cnblogs.com/duanguyuan/p/16201088.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有