基準測試 - Arch Linux 中文维基

跳至內容

# 基準測試

出自 Arch Linux 中文维基
翻譯狀態：

- 本文（或部分內容）譯自 Benchmarking，最近一次同步於 2024-07-10，若英文版本有所更改，則您可以幫助同步與翻譯更改的內容。
- 您可以在 ArchWiki 的對應頁面找到本文翻譯的原始修訂歷史。
- 本文可能與英文原文存在出入。

相關文章

- 性能優化
- Stress testing
- Sysstat

所謂基準測試，就是通過一個統一的流程來測試性能，並將其結果和其它系統測到的結果或一個被廣泛接受的標準相比較的行為。這種計算系統性能的統一流程可以幫助解答一些問題，比如：

- 系統是否發揮正常？
- 應該用哪個版本的驅動以達到最佳性能？
- 系統是否能夠勝任某任務？

許多工具可以測試系統性能，下面列出可用的工具。

## 獨立工具

### UnixBench

安裝 unixbenchAUR，在終端中運行 ubench 來開始測評。

另請閱讀：

- https://github.com/kdlucas/byte-unixbench
- https://github.com/kdlucas/byte-unixbench/blob/master/UnixBench/USAGE

### interbench

interbench 被設計用於測試 Linux 的交互性。它被用於測試修改 Linux 內核設計或系統配置後的效果，包括如 CPU，I/O 調度器和文件系統及參數的變更等。

提示：可通過更細緻的測試來比較不同硬體。

可通過 AUR 獲取 interbench：interbenchAUR。

另請閱讀：

- Realtime process management
- 進階網絡流量控制
- Linux-ck
- Linux-pf

### fio

fio包 (Flexible I/O Tester) 是一個實用工具，可以幫助模擬多種不同的工作負載（比如多個線程使用異步 I/O 來發起讀請求）。Fio 會 spawn 一些線程或者進程來做用戶指定的一些特定種類的 I/O。Docs

示例用法:

    # fio --filename=/mnt/test.fio --size=8GB --direct=1 --rw=randrw --bs=4k --ioengine=libaio --iodepth=256 --runtime=120 --numjobs=4 --time_based --group_reporting --name=iops-test-job --eta-newline=1

### ttcp

ttcp（Test TCP）測試任意網絡連接的 P2P 帶寬。需要在（被測試帶寬的）設備兩端都安裝該程序。

可以在 AUR 找到不同版本的 ttcp：

- ttcpAUR
- nuttcpAUR

### iperf

iperf 是簡單的 P2P 帶寬測試工具，可以用於 TCP 或 UDP。它的輸出格式非常好，且帶有並發測試模式。

可以安裝 iperf包，或不同版本的 iperf3包。

### time

time(1) 命令通過顯示某條命令從調用到終止之間的時間，提供命令運行的耗時統計信息。time包 包含了 `time` 命令，某些命令行解釋器也提供了 `time` 作為內置命令。

    $ time tar -zxvf archive.tar.gz

### hdparm

可以用 hdparm（hdparm包）測試存儲介質。Using hdparm with the `-Tt` switch, one can time sequential reads. This method is independent of partition alignment!

    # hdparm -Tt /dev/sdX

    /dev/sdX:
    Timing cached reads:   x MB in  y seconds = z MB/sec
    Timing buffered disk reads:  x MB in  y seconds = z MB/sec

注意：根據 hdparm(8) § T 參數的描述，一次測試需要執行上述命令 2-3 次，並手動計算平均值以準確評估讀取速度。

### gnome-disks

There is a graphical benchmark called gnome-disks contained in the gnome-disk-utility包 package that will give min/max/ave reads along with average access time and a nice graphical display. This method is independent of partition alignment!

    # gnome-disks

Users will need to navigate through the GUI to the benchmark button ("More actions..." > "Benchmark Volume..."). Example

### KDiskMark

kdiskmark包 is an HDD and SSD benchmark tool with a very friendly graphical user interface. KDiskMark with its presets and powerful GUI calls Flexible I/O Tester and handles the output to provide an easy to view and interpret comprehensive benchmark result.

### systemd-analyze

    $ systemd-analyze plot > boot.svg

上述命令會把啟動順序畫一個詳細的圖，包括：內核用的時間，用戶態時間，每個服務占用的時間。參考示例

### dd

The dd utility can be used to measure both reads and writes. This method is dependent on partition alignment! In other words, if you failed to properly align your partitions, this fact will be seen here since you are writing and reading to a mounted filesystem.

注意：This method requires the command to be executed from a mounted partition on the device of interest!

First, enter a directory on the SSD with at least 1.1 GB of free space (and one that gives your user wrx permissions) and write a test file to measure write speeds and to give the device something to read:

    $ dd if=/dev/zero of=/path/to/SSD/tempfile bs=1M count=1024 conv=fdatasync,notrunc status=progress

    1024+0 records in
    1024+0 records out
    v bytes (w MB, x MiB) copied, y s, z MB/s

提示：See dd-benchmark for an explanation on the requirement to `sync` and further related `dd` options.

Next, clear the buffer-cache to accurately measure read speeds directly from the device:

    # echo 3 > /proc/sys/vm/drop_caches
    $ dd if=tempfile of=/dev/null bs=1M count=1024 status=progress

    1024+0 records in
    1024+0 records out
    v bytes (w MB, x MiB) copied, y s, z MB/s

Now that the last file is in the buffer, repeat the command to see the speed of the buffer-cache:

    $ dd if=tempfile of=/dev/null bs=1M count=1024 status=progress

    1024+0 records in
    1024+0 records out
    v bytes (w MB, x MiB) copied, y s, z MB/s

注意：One should run the above command 4-5 times and manually average the results for an accurate evaluation of the buffer read speed.

Finally, delete the temp file

    $ rm tempfile

注意：Some SSD controllers have compression hardware, which may skew benchmark results. See https://www.pugetsystems.com/labs/articles/SSDs-Advertised-vs-Actual-Performance-179/

### dcfldd

Dcfldd does not print the average speed in MB/s like good old dd does but with time you can work around that.

Time the run clearing the disk:

    # time dcfldd if=/dev/zero of=/dev/sdX bs=4M

    18944 blocks (75776Mb) written.dcfldd:: No space left of device
    real     16m17.033s
    user     0m0.377s
    sys      0m51.160s

Calculate MB/s by dividing the output of the dcfldd command by the time in seconds. For this example: 75776Mb / (16.4 min * 60) = 77.0 MB/s.

### 7z

7z benchmark command can be used to measure the CPU speed in MIPS and also to check RAM for errors. Just install p7zip and run the command below. More detailed information can be found at [1].

    $ 7z b

### peakperf

peakperf-gitAUR is a microbenchmark that achieves peak performance on x86_64 CPUs. Some issues may reduce the performance provided by your CPU, like CPU cooling. With peakperf you can check if your CPU provides the full power it is capable of doing.

You can calculate the performance (measured in GFLOP/s) you should get using your CPU (see [2]) and compare it with the performance that peakperf gives you. If both values are the same (or very similar), your CPU behaves as it should.

注意：Even though the goal of peakperf is to test the CPU, it is also a great way to test your cooling, since it will throttle your CPU to the limit.

### cryptsetup

cryptsetup benchmark can be used to measure the speed of various cryptographic algorithms (ciphers).

    $ cryptsetup benchmark

## 軟體集

### Bonnie++

bonnie++包 是用 C++ 重寫的原 Bonnie 測試集，主要測試硬碟和文件系統性能。

警告：By default, bonnie++ write at least twice the RAM size on disk. If you want to preserve your SSD, use non default option.
注意：原 Bonnie 軟體集不是以 GPL 或其他兼容許可證發布。

另請閱讀：

- 作者的網站
- Wikipedia:Bonnie++

### IOzone

IOzone 用於測量計算機的文件系統大致性能。

可通過 AUR 安裝該軟體：iozoneAUR。

另請查看論壇帖子：iozone 評估 I/O 調度... 結果並不是您期望的！。

### HardInfo

hardinfo2AUR 可以收集系統硬體和作業系統信息，測試系統性能，生成 HTML 或純文本格式的可列印報表。HardInfo 會測試 CPU 和 FPU，並有簡潔的 GTK 界面。

### Phoronix 測試套件

https://www.phoronix-test-suite.com/ Phoronix 測試套件]是目前最全面的測試和基準測試平台，它提供了一個可擴展的框架，可輕鬆添加新的測試。該軟體旨在以簡潔、可重現和易用的方式有效執行定性和定量基準測試。

Phoronix 測試套件基於 Phoronix.com 自 2004 年以來進行的大量測試和內部工具，並得到了主流計算機硬體和軟體供應商的支持。該軟體是開源軟體，採用 GNU GPLv3 許可。

Phoronix 測試套件最初是為 Linux 自動測試而開發的，後來增加了對 OpenSolaris、Apple macOS、Microsoft Windows 和 BSD 系統的支持。Phoronix 測試套件包括一個輕量級處理核心（pts-core），每個測試都由基於 XML 的配置文件和相關資源腳本組成。從基準測試安裝到實際測試，再到重要硬體和軟體組件的解析，整個過程高度自動化且完全可重複，僅要求用戶確認操作。

Phoronix 測試套件與 OpenBenchmarking.org 對接，這是一個協作式網絡平台，具有集中存儲測試結果、共享測試配置文件和結果、高級分析等功能。Phoromatic 是一個企業組件，具有遠程管理功能，可協調多個系統的測試執行。

可通過 phoronix-test-suiteAUR 來安裝該套件。另外也可以通過 phoronix-test-suite-gitAUR 獲取開發版本的套件。

### S

S, an I/O Benchmark Suite, is a small collection of scripts to measure storage I/O performance.

It has been developed by algodev, the team behind the BFQ scheduler.

Download or clone the project, install its dependencies and run it as root (privileges needed to change disk scheduler).

### s-tui

s-tui is an aesthetically pleasing and useful curses-style interface that shows graphs of CPU frequency, utilization, temperature, power consumption and has a built in stress tester.

### sysbench

sysbench包 is an all-round multi-threaded benchmark tool. Written in C and Perl, it can be used in CLI directly to benchmark filesystem, DRAM, CPU, thread-based scheduler and POSIX mutex performance. Or it can be used as Lua script interpreter to benchmark any arbitrarily complex workload. It provides a collection of scripts for database benchmarks.

## 快閃記憶體介質

可通過 iozoneAUR 來量化性能。持續讀寫值可以（但通常不能）與 I/O 繁重操作的實際用例相關聯，例如在系統更新時解壓並寫入大量文件。在這種情況下可以考慮使用小文件的隨機寫入速度。

該示例使用 4k 記錄大小測試一個 10M 文件：

    $ iozone -e -I -a -s 10M -r 4k -i 0 -i 1 -i 2

    ...

                                                                    random   random
                  kB  reclen    write  rewrite    read    reread    read     write
               10240       4      661      649     5802     5822     3892      624

注意：單位是 KB/s。

## Graphics

### Basemark GPU

Basemark GPU is an evaluation tool to analyze and measure graphics API (OpenGL 4.5, OpenGL ES 3.1, Vulkan and Microsoft DirectX 12) performance across mobile and desktop platforms. Basemark GPU targets both Desktop and Mobile platforms by providing both High Quality and Medium Quality modes. The High-Quality mode addresses cutting-edge Desktop workloads while the Medium Quality mode addresses equivalent Mobile workloads.

If you are using AMD GPU and have several vulkan implementations installed simultaneously, in the Test page you will see them as separate GPUs in Graphics Device dropdown list.

Basemark GPU is available in basemarkAUR package.

### Blender-benchmark

Blender-benchmark will gather information about the system, such as operating system, RAM, graphics cards, CPU model, as well as information about the performance of the system during the execution of the benchmark. After that, the user will be able to share the result online on the Blender Open Data platform, or to save the data locally.

Blender-benchmark is available in the blender-benchmarkAUR package.

### GFXBench

GFXBench is a high-end graphics benchmark that measures mobile and desktop performance with next-gen graphics features across all platforms. As a true cross-API benchmark, GFXBench supports all the industry-standard and vendor-specific APIs including OpenGL, OpenGL ES, Vulkan, Metal, DirectX/Direct3D and DX12.

Vulkan API tests are currently under development and are only available for their corporate partners.

GFXBench is available in gfxbenchAUR package.

### glmark2

glmark2 is an OpenGL 2.0 and ES 2.0 benchmark.

glmark2 is available in glmark2包 package.

### glxgears

glxgears 是一款流行的 OpenGL 測試工具，它可以渲染非常簡單的 OpenGL 測試並輸出幀數。雖然 glxgears 可以測試圖形驅動程序的直接渲染能力，但它是一個過時的工具，不能代表 GNU/Linux 圖形顯示的現狀和 OpenGL 的整體能力。glxgears 僅測試了遊戲中可能用到的一小部分 OpenGL 功能，因此在 glxgears 中記錄到的性能提升可能無法在遊戲中被體現出來。更多信息請參見這裡。

可通過 mesa-utils包 或 lib32-mesa-utils包（適用於 multilib）獲取 glxgears。

### GpuTest

GpuTest is a cross-platform (Windows, Linux and Max OS X) GPU stress test and OpenGL benchmark. GpuTest comes with several GPU tests including some popular ones from Windows'world (FurMark or TessMark).

GpuTest is available in gputestAUR package.

### intel-gpu-tools

intel-gpu-tools gives you some top-like info for the integrated GPU. This can be quite useful in diagnosing GPU acceleration issues.

To use it, install the intel-gpu-tools包 package.

### MangoHud

See MangoHud.

### Unigine 引擎

Unigine 公司基於他們的圖形引擎製造了多個現代化 OpenGL 基準測試，特性如下：

- 像素動態光照
- 普通和視差映射
- 64 位 HDR 渲染
- 體積霧和光
- 強大的粒子系統：火焰、煙、爆炸
- 可擴展著色（GLSL/HLSL）
- 後處理：景深、折射、輝光、模糊、色彩校正等。

最近，Unigine 開始基準被對系統進行超頻的用戶所使用。尤其是 Heaven 被用於超頻的初始穩定性測試。

可以在 AUR 找到這些基準測試：

- unigine-sanctuaryAUR (2007)
- unigine-tropicsAUR (2008)
- unigine-heavenAUR (2009)
- unigine-valleyAUR (2013)
- unigine-superpositionAUR (2017)

### vkmark

vkmark is an extensible Vulkan benchmarking suite with targeted, configurable scenes.

vkmark is available in vkmark包 package.

## 參閱

- Linux 基準測試主頁
- Phoronix.com
- Interbench 主頁
- Unigine.com

分類：​

- 硬體

基準測試
新增話題