sysbench CPU Benchmark
The sysbench CPU test measures processor throughput by verifying prime numbers across configurable thread counts, reporting events per second and latency. It is a lightweight, scriptable way to compare CPUs and study thread scaling.
sysbench is a scriptable, multi-threaded benchmark tool best known for database testing, but its built-in CPU test mode is a popular lightweight way to measure raw processor throughput. Because sysbench is small, scriptable, and available in most Linux distributions, its CPU test is a common quick check for comparing servers, containers, and cloud instances.
The CPU test works by repeatedly verifying prime numbers up to a configurable limit using trial division. This is a deterministic, integer-and-arithmetic-heavy workload that keeps the processor busy without touching disk or network, isolating CPU and, to a lesser extent, the compiler and math library performance.
What It Measures
The primary metric is events per second — how many prime-verification operations the CPU completes per second — reported per thread and in aggregate. sysbench also reports latency statistics (average, 95th percentile) per event and total execution time. Running with different thread counts reveals thread scaling, showing how throughput grows as cores are added.
Methodology
The user sets a prime limit (commonly 10000 or 20000) and a thread count, optionally a fixed run time or event count. Each thread independently verifies primes, and sysbench aggregates throughput and latency across threads. Pinning the prime limit and thread count makes runs reproducible. To test scaling, the same prime limit is run at increasing thread counts up to and beyond the core count.
How to Interpret Results
Use single-thread events per second to compare per-core performance and multi-thread aggregate to compare total CPU capacity. Throughput should rise nearly linearly with threads up to the physical core count, then flatten or rise slowly once hyper-threads or contention dominate — the shape of that curve reveals effective parallelism. Keep the prime limit constant across comparisons, since changing it changes the absolute numbers.
Limitations
The prime-verification workload is narrow: it stresses integer arithmetic and branch behavior but ignores floating point, memory bandwidth, vector units, and cache effects that dominate many real applications. Results therefore correlate only loosely with real-world performance. The benchmark is sensitive to compiler optimization and CPU frequency scaling. It is best used as a fast, repeatable relative indicator rather than a comprehensive measure of CPU capability.