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的性能。
本文同步發佈於: