基准测试

来自 Arch Linux 中文维基

所谓基准测试,就是通过一个统一的流程来测试性能,并将其结果和其它系统测到的结果或一个被广泛接受的标准相比较的行为。这种计算系统性能的统一流程可以帮助解答一些问题,比如:

  • 系统是否发挥正常?
  • 应该用哪个版本的驱动以达到最佳性能?
  • 系统是否能够胜任某任务?

许多工具可以测试系统性能,下面列出可用的工具。

独立工具[编辑 | 编辑源代码]

UnixBench[编辑 | 编辑源代码]

安装 unixbenchAUR,在终端中运行 ubench 来开始测评。

另请阅读:

interbench[编辑 | 编辑源代码]

interbench 被设计用于测试 Linux 的交互性。它被用于测试修改 Linux 内核设计或系统配置后的效果,包括如 CPU,I/O 调度器和文件系统及参数的变更等。

提示:可通过更细致的测试来比较不同硬件。

可通过 AUR 获取 interbench:interbenchAUR

另请阅读:

fio[编辑 | 编辑源代码]

fio (Flexible I/O Tester) is a utility that can simulate various workloads such as several threads issuing reads using asynchronous I/O. Fio spawns a number of threads or processes doing a particular type of I/O action as specified by the user. Docs

Example usage:

# 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:

iperf[编辑 | 编辑源代码]

iperf 是简单的 P2P 带宽测试工具,可以用于 TCP 或 UDP。它的输出格式非常好,且带有并发测试模式。

可以安装 iperf,或不同版本的 iperf3

time[编辑 | 编辑源代码]

time(1) 命令通过显示某条命令从调用到终止之间的时间,提供命令运行的耗时统计信息。time 包含了 time 命令,某些命令行解释器也提供了 time 作为内置命令。

$ time tar -zxvf archive.tar.gz

hdparm[编辑 | 编辑源代码]

可以用 hdparmhdparm)测试存储介质。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 或其他兼容许可证发布。

另请阅读:

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-utilslib32-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 找到这些基准测试:

vkmark[编辑 | 编辑源代码]

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

vkmark is available in vkmark package.

参阅[编辑 | 编辑源代码]