CPU speed varies with cooling and load. sysbench measures repeatable single-thread and multithread CPU throughput for comparisons under the same conditions.
sysbench cpu calculates prime numbers with one or more worker threads and reports throughput as events per second. The single-thread test measures one worker’s throughput, while an all-thread run shows how the workload scales. This synthetic prime-number workload is not a universal score for every application.
Keep the benchmark conditions consistent when comparing results. Use the same sysbench version, threads value, test length, prime limit, power mode, and cooling state, and avoid running it beside other CPU-heavy workloads because contention changes the reported event rate and latency percentiles. All-thread runs can slow other work while the benchmark is running.
Steps to benchmark CPU performance on Linux with sysbench:
- Refresh the package index on Ubuntu or Debian.
$ sudo apt update
- Install sysbench from the distribution repository on Ubuntu or Debian.
$ sudo apt install sysbench
Other Linux distributions need sysbench installed through their own package manager; the CPU benchmark commands are the same.
- Check how many processing units are available to the current process.
$ nproc 8
This value supplies the worker count for all-thread runs in the current host, guest, or container.
- Run the single-thread baseline.
$ sysbench cpu run sysbench 1.0.20 (using system LuaJIT 2.1.1761786044) Running the test with following options: Number of threads: 1 Initializing random number generator from current time Prime numbers limit: 10000 Initializing worker threads... Threads started! CPU speed: events per second: 6501.69 General statistics: total time: 10.0002s total number of events: 65023 Latency (ms): min: 0.10 avg: 0.15 max: 165.85 95th percentile: 0.12 sum: 9909.66 Threads fairness: events (avg/stddev): 65023.0000/0.00 execution time (avg/stddev): 9.9097/0.00The default sysbench cpu run uses one worker thread for 10 seconds with a prime limit of 10000.
- Run the same benchmark across all exposed threads.
$ sysbench cpu --threads=8 run sysbench 1.0.20 (using system LuaJIT 2.1.1761786044) Running the test with following options: Number of threads: 8 Initializing random number generator from current time Prime numbers limit: 10000 Initializing worker threads... Threads started! CPU speed: events per second: 27978.61 General statistics: total time: 10.0237s total number of events: 280467 Latency (ms): min: 0.10 avg: 0.28 max: 476.12 95th percentile: 0.13 sum: 79752.75 Threads fairness: events (avg/stddev): 35058.3750/5880.77 execution time (avg/stddev): 9.9691/0.02If nproc reports a value other than 8, replace 8 in both all-thread commands with that value. The difference from the single-thread baseline shows scaling for this workload, rather than a comparison under identical thread settings.
- Run a longer all-thread benchmark with the same thread count.
$ sysbench cpu --threads=8 --time=15 run sysbench 1.0.20 (using system LuaJIT 2.1.1761786044) Running the test with following options: Number of threads: 8 Initializing random number generator from current time Prime numbers limit: 10000 Initializing worker threads... Threads started! CPU speed: events per second: 22004.25 General statistics: total time: 15.0039s total number of events: 330169 Latency (ms): min: 0.10 avg: 0.36 max: 821.40 95th percentile: 0.26 sum: 119245.84 Threads fairness: events (avg/stddev): 41271.1250/4240.34 execution time (avg/stddev): 14.9057/0.06Higher events per second means greater CPU throughput for this prime-number workload. A lower avg latency and a lower 95th percentile indicate shorter event completion times; the percentile estimates the time within which 95% of events finish. total number of events counts completed calculations, so a longer run can complete more events even at a lower rate.
The eight-thread results above show 27978.61 events per second over 10 seconds and 22004.25 over 15 seconds, while the 95th-percentile latency rises from 0.13 to 0.26 ms. The longer run has lower throughput and higher event latency despite completing more events. Repeated comparisons need matching thread counts, durations, prime limits, and conditions.
The 15-second run is longer than the default 10 seconds, but does not guarantee that the CPU reaches a stable temperature. A lower event rate alone does not prove thermal throttling.