Introduction / Why This Is Needed
CPU performance testing in Linux allows you to objectively evaluate computation speed, stability under load, and compare results with reference values. This is critically important when selecting hardware for a server, tuning a system for high-load tasks (virtualization, compilation, rendering), or verifying performance after overclocking. As a result, you will obtain numerical metrics that will help you make an informed decision.
Requirements / Preparation
Before you begin, ensure that:
- You have terminal access with sudo privileges (for installing packages).
- Your system is updated:
sudo apt update && sudo apt upgrade -y(for Debian/Ubuntu) orsudo dnf upgrade -y(for Fedora/CentOS). - You are working on a physical machine (results on a virtual machine may be distorted).
- All non-critical applications are closed, and the system is running in Performance mode (you can check with the command
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor— it should outputperformance).
Step-by-Step Instructions
Step 1: Install Necessary Tools
Install the core utilities. For Debian/Ubuntu:
sudo apt install sysbench stress-ng
For Fedora/CentOS/RHEL:
sudo dnf install sysbench stress-ng
💡 Tip: Geekbench 6 is a proprietary tool. Download it from the official website, unpack it, and grant execute permissions:
chmod +x geekbench6.
Step 2: Check CPU Configuration
Identify your processor's architecture:
lscpu
Pay attention to these lines:
CPU(s):— total number of logical cores.Thread(s) per core:— threads per core (usually 1 or 2). You will need this data to correctly configurestress-ng.
Step 3: Run a CPU Test with sysbench
sysbench will perform a test using simple mathematical operations (prime number calculation). Run:
sysbench cpu --cpu-max-prime=20000 run
What this command does: calculates all prime numbers up to 20000 across all available cores. The result is the total execution time in seconds. Lower time means higher performance.
Step 4: Run a Stress Test with stress-ng
stress-ng creates intensive load, checking stability and heat output. To fully load all cores for 60 seconds:
stress-ng --cpu $(nproc) --timeout 60s
Important: this test can significantly increase CPU temperature. Monitor it (for example, with the command watch -n 1 sensors). If the temperature approaches the TjMax (usually 90-100°C), stop the test (Ctrl+C).
Step 5: Run the Comprehensive Geekbench Benchmark
Geekbench 6 evaluates both single-core and multi-core performance using real-world scenarios (compression, navigation, machine learning). Run:
./geekbench6
The results will be printed to the terminal and uploaded to the Geekbench server (if internet is available). You will receive two scores: Single-Core Score and Multi-Core Score. Save the link to the detailed report.
Step 6: Compare and Record Results
For convenience, save the output to files:
sysbench cpu --cpu-max-prime=20000 run > ~/cpu_benchmarks/sysbench.txt
stress-ng --cpu $(nproc) --timeout 60s 2>&1 | tee ~/cpu_benchmarks/stressng.log
./geekbench6 > ~/cpu_benchmarks/geekbench.txt
Create the ~/cpu_benchmarks directory if it doesn't exist. Now you have all the data needed to compare with other systems or after changes (such as overclocking).
Verifying the Results
A successful benchmark will complete without access errors and output numerical results. For sysbench, look for the total time: line. For stress-ng, the log will show the number of operations completed and the time. For Geekbench, look for the final scores. If the system did not crash during the stress test, the CPU is stable.
Potential Issues
stress-ng: error: cpu stressor failederror: insufficient permissions or incompatible version. Ensure you are running withsudoand that yourstress-ngversion is up-to-date.- System freezes or overheats: reduce the test duration (
--timeout 30s) or the number of cores (instead of$(nproc), specify something like4). Improve cooling. - Geekbench fails to launch: check if dependencies are installed (libc6, libstdc++6). On Ubuntu/Debian:
sudo apt install libc6 libstdc++6. - Results vary significantly between runs: ensure there is a cooldown period between tests (5-10 minutes) and that the system is not performing background tasks (use
topto check).
Additional Tips
- To test single-core performance with
stress-ng, specify--cpu 1. - To check the impact of the storage drive on overall performance, add the
sysbench fileiotest. - Regularly compare your results with stock (default) settings to evaluate the effect of overclocking or system changes.