UnixBench is a performance testing tool for Unix-like systems (Unix, BSD, Linux). It is an open-source utility widely used to test the performance of Linux hosts. The main test items in UnixBench include: system calls, read/write, processes, graphical tests, 2D, 3D, pipes, arithmetic, the C library, and other system benchmark data.
The latest version is UnixBench 5.1.3, which includes system and graphic tests. If you need to test graphics, you need to modify the Makefile and do not comment out “GRAPHIC_TESTS
= defined”. At the same time, the system needs to provide the x11perf command and the gl_glibs library.
The script below uses the latest UnixBench 5.1.3 for testing, with the graphic-related test items commented out (most VPS instances do not have a graphics card or only have integrated graphics, so graphics performance does not need to be tested). After running for 10–30 minutes (depending on the number of CPU cores, computation time varies), it will produce a score—the higher, the better.
Test method:
wget --no-check-certificate https://github.com/teddysun/across/raw/master/unixbench.sh chmod +x unixbench.sh ./unixbench.sh
Test items:
Dhrystone 2 using register variables
This test is used to measure string
handling. Because there are no floating-point operations, it is heavily affected by hardware
and software design, compiler and linker
options, code
optimization, cache memory, wait
states, and integer data types.
Double-Precision Whetstone
This test measures the speed and efficiency of floating-point operations. It includes several modules, each containing a set of operations used in scientific computing. A wide range of
C functions—sin, cos, sqrt, exp, log—
are used for integer and floating-point math operations, array access, conditional
branches, and program calls. This test also measures both integer and floating-point arithmetic.
Execl Throughput
This test examines how many execl system calls can be executed per second. The execl
system call is a member of the exec
family of functions. Like several other similar commands, it is a front end for the execve()
function.
File copy
This test measures the rate of transferring data from one file to another. Each test uses buffers of different sizes. This test, which targets file
read, write, and copy operations, counts the number of file read, write, and copy operations performed within a specified time period (10s by default).
Pipe Throughput
A pipe is the simplest way for processes to communicate. Here, Pipe
Throughput refers to the number of times per second that a process can write 512
bytes of data to a pipe and then read it back. It should be noted that pipe throughput
does not correspond to a real-world scenario in actual programming.
Pipe-based Context Switching
This test measures how many times per second two processes can exchange an ever-increasing integer through a pipe. This is somewhat similar to certain real-world programming applications. The test program first creates a child process, then performs two-way pipe communication with that child process.
Process Creation
Tests how many times per second one process can create a child process and then reap it again (the child process always exits immediately). The focus of process
creation is the creation of the new process’s process control
block and memory allocation—in other words, it directly targets memory bandwidth. Generally speaking, this test is used to compare different implementations of the operating system’s process creation system call.
System Call Overhead
Tests the cost of entering and leaving the operating system kernel, that is, the cost of a single system call. It achieves this by using a small program that repeatedly calls the
getpid function.
Shell Scripts
Tests how many times per second a process can concurrently start n
copies of a shell script, where n usually takes the values 1, 2, 4, and 8. (In my test, I used 1 and
8.) This script performs a series of transformations on a data file.
Below are the benchmark results from one of my 512MB, dual-core, OpenVZ VPSs:
BYTE UNIX Benchmarks (Version 5.1.3)
System: vpn: GNU/Linux
OS: GNU/Linux -- 2.6.32-042stab076.8 -- #1 SMP Tue May 14 20:38:14 MSK 2013
Machine: i686 (i386)
Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
CPU 0: Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4533.6 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
CPU 1: Intel(R) Xeon(R) CPU L5520 @ 2.27GHz (4533.6 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
09:41:17 up 31 days, 9:21, 1 user, load average: 0.23, 0.05, 0.02; runlevel 3
------------------------------------------------------------------------
Benchmark Run: Mon Jul 29 2013 09:41:17 - 10:09:29
2 CPUs in system; running 1 parallel copy of tests
Dhrystone 2 using register variables 17172222.3 lps (10.0 s, 7 samples)
Double-Precision Whetstone 2600.2 MWIPS (10.0 s, 7 samples)
Execl Throughput 4152.8 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 622759.5 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 172634.3 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 1218236.9 KBps (30.0 s, 2 samples)
Pipe Throughput 1416230.5 lps (10.0 s, 7 samples)
Pipe-based Context Switching 206509.4 lps (10.0 s, 7 samples)
Process Creation 8568.6 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 3145.9 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 528.3 lpm (60.0 s, 2 samples)
System Call Overhead 1528474.7 lps (10.0 s, 7 samples)
System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 17172222.3 1471.5
Double-Precision Whetstone 55.0 2600.2 472.8
Execl Throughput 43.0 4152.8 965.8
File Copy 1024 bufsize 2000 maxblocks 3960.0 622759.5 1572.6
File Copy 256 bufsize 500 maxblocks 1655.0 172634.3 1043.1
File Copy 4096 bufsize 8000 maxblocks 5800.0 1218236.9 2100.4
Pipe Throughput 12440.0 1416230.5 1138.4
Pipe-based Context Switching 4000.0 206509.4 516.3
Process Creation 126.0 8568.6 680.0
Shell Scripts (1 concurrent) 42.4 3145.9 742.0
Shell Scripts (8 concurrent) 6.0 528.3 880.5
System Call Overhead 15000.0 1528474.7 1019.0
========
System Benchmarks Index Score 960.4
------------------------------------------------------------------------
Benchmark Run: Mon Jul 29 2013 10:09:29 - 10:39:56
2 CPUs in system; running 2 parallel copies of tests
Dhrystone 2 using register variables 16851634.7 lps (10.0 s, 7 samples)
Double-Precision Whetstone 5182.9 MWIPS (10.0 s, 7 samples)
Execl Throughput 4101.9 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 635244.9 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 174430.2 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 1219982.0 KBps (30.0 s, 2 samples)
Pipe Throughput 1387297.9 lps (10.0 s, 7 samples)
Pipe-based Context Switching 196296.1 lps (10.0 s, 7 samples)
Process Creation 10889.9 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 4073.7 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 550.5 lpm (60.2 s, 2 samples)
System Call Overhead 1538517.4 lps (10.0 s, 7 samples)
System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 16851634.7 1444.0
Double-Precision Whetstone 55.0 5182.9 942.3
Execl Throughput 43.0 4101.9 953.9
File Copy 1024 bufsize 2000 maxblocks 3960.0 635244.9 1604.2
File Copy 256 bufsize 500 maxblocks 1655.0 174430.2 1054.0
File Copy 4096 bufsize 8000 maxblocks 5800.0 1219982.0 2103.4
Pipe Throughput 12440.0 1387297.9 1115.2
Pipe-based Context Switching 4000.0 196296.1 490.7
Process Creation 126.0 10889.9 864.3
Shell Scripts (1 concurrent) 42.4 4073.7 960.8
Shell Scripts (8 concurrent) 6.0 550.5 917.5
System Call Overhead 15000.0 1538517.4 1025.7
========
System Benchmarks Index Score 1058.3
