CPU benchmarking utility for Linux
I am looking for a utility that will benchmark CPU performance under single and multi threaded instances. At present I have an old rig with a dual core CPU (E7500) at 3.6 Ghz and I am looking at replacing it with a quad core CPU (Q9400) at 3.2 Ghz. I want to see if I will notice a performance improvement with the extra 2 cores (albeit with a drop in core speed). I will clock the CPU’s with the same FSB (400Mhz) and the cache size is the same per CPU (1.5MB) and for what its worth I have 4GB ram (with potential to upgrade to 6GB) My son mainly uses the PC for playing TF2 (which I am trying to still get working under Linux) and I also use it for some video encoding (MP4 to DVD) I am thinking that I could be better off with the quad core but any feedback would be appreciated.
There is Geekbench which can compare CPUs (there are already existing test results for the e7500 and the q9400, though many are in drastically different setups, which will have different bus speeds etc.
5 Answers 5
Actually there is a a tool named sysbench .
sudo apt-get install sysbench
To do CPU benchmarking you can use:
This will run a single-threaded CPU benchmark. To use more than one thread, use:
sysbench --threads=16 cpu run
—cpu-max-prime=20000 is optional, the default being 10000 . I suggest to keep the default and fiddle with —max-requests instead (which is the number of operations performed)
Also note that by default this is a single-threaded test. For testing N cores you can use —num-threads=N , and compare results using the per-request statistics output.
With newer version, the —test= option can be omitted, just use sysbench cpu. . Otherwise sysbench 1.0.18 prints: WARNING: the —test option is deprecated. You can pass a script name or path on the command line without any options.
Alternatively, one can use stress-ng . It has a CPU stress test as one of the many stress tests built into the tool. The cpu stress test contains many different CPU stress methods covering integer, floating point, bit operations, mixed compute, prime computation, and a wide range of computations.
sudo apt-get install stress-ng
To see the cpu related stress methods use:
To benchmark, for example, matrix product for 60 seconds on 4 CPU threads, use:
stress-ng --cpu 4 --cpu-method matrixprod --metrics-brief --perf -t 60 stress-ng: info: [15876] dispatching hogs: 4 cpu stress-ng: info: [15876] successful run completed in 60.00s (1 min, 0.00 secs) stress-ng: info: [15876] stressor bogo ops real time usr time sys time bogo ops/s bogo ops/s stress-ng: info: [15876] (secs) (secs) (secs) (real time) (usr+sys time) stress-ng: info: [15876] cpu 71657 60.00 239.60 0.00 1194.25 299.07 stress-ng: info: [15876] cpu: stress-ng: info: [15876] 885,244,279,148 CPU Cycles 14.75 B/sec stress-ng: info: [15876] 1,289,303,858,968 Instructions 21.49 B/sec (1.456 instr. per cycle) stress-ng: info: [15876] 201,499,961,692 Cache References 3.36 B/sec stress-ng: info: [15876] 790,424 Cache Misses 13.17 K/sec ( 0.00%) stress-ng: info: [15876] 157,689,508,544 Branch Instructions 2.63 B/sec stress-ng: info: [15876] 1,232,539,732 Branch Misses 20.54 M/sec ( 0.78%) stress-ng: info: [15876] 5,755,605,036 Bus Cycles 95.92 M/sec stress-ng: info: [15876] 817,296,440,876 Total Cycles 13.62 B/sec stress-ng: info: [15876] 8,532 Page Faults Minor 142.19 sec stress-ng: info: [15876] 0 Page Faults Major 0.00 sec stress-ng: info: [15876] 220 Context Switches 3.67 sec stress-ng: info: [15876] 0 CPU Migrations 0.00 sec stress-ng: info: [15876] 0 Alignment Faults 0.00 sec
6 Useful Linux Apps to Stress Test and Benchmark CPU Performance
Benchmark and stress test methods are often used to gauge the performance of desktop PCs and servers. These tests are also useful in finding hardware problems and system anomalies that are observed only when a system is under heavy load.
This article will list various utilities to perform CPU benchmarks and stress tests on your system. While many of these apps provide options to test other hardware components as well, this article will focus on CPU tests only.
HardInfo (Benchmark Only)
HardInfo is a graphical utility for Linux that displays information about various hardware components in your PC like processor, RAM modules, sensors, hard drives and so on. It also supports exporting a detailed report about your system in txt or html format so that you can share it with your friends, compare it with other systems or use it for debugging purposes.
Besides showing general information about your system, HardInfo provides a few benchmark tools to measure the performance of your hardware. As far as CPU benchmarking is concerned, it includes five methods: CPU Blowfish, CPU CryptoHash, CPU Fibonacci, CPU N-Queens and CPU Zlib.
To install HardInfo in Ubuntu, run the command below:
To run a CPU benchmark, click on any benchmark method under “Benchmarks” section, as shown in the screenshot below.
Once the benchmark has finished, HardInfo will tell you if a lower or higher score is better. It also displays scores for CPUs made by other vendors for easy comparison.
Sysbench (Benchmark Only)
Sysbench, as the name suggests, is a command line app to run benchmarks on your system. Written in Lua, Sysbench is mainly intended for doing database benchmarking. However it includes options to test CPU, memory and file throughput as well.
To install Sysbench in Ubuntu, run the command below:
To start a benchmark using Sysbench, run the following command:
- “cpu” is the test type
- “threads” is the number of threads created by sysbench to perform multi-threaded benchmarking
You can use other command line switches to customize the benchmark behavior. More details about these options can be found here.
Once the test has finished, you can use the “events per second” variable to gauge the performance of your CPU. Unfortunately unlike HardInfo, Sysbench does not provide benchmark results of other CPU models made by various hardware vendors out there. If you have multiple computers, you can run the test on both and then compare the numbers. Higher is the number of events per second, better is the CPU performance.
Stress (Stress Test Only)
Stress is a simple command line utility to conduct CPU, memory and disk input-output stress tests.
You can install stress in Ubuntu by running the following command:
Note that Stress will not run any benchmark test on your system, instead it will consistently hammer the CPU and make it run at 100%. You are advised to close all the running apps before doing a test. Running Stress for a longer period can crash the system and you may need to do a hard reboot to recover the system.
You can start the stress test by running the command below where “cpu” refers to the number of threads used for performing the test. To stop the test anytime, close the terminal or press to make it stop.
I used Stress extensively when I built a new PC for myself a year back. It helped me greatly in tweaking fan speeds in BIOS for improved cooling.
Stress-ng (Stress Test Only)
Stress-ng is an updated implementation of Stress tool mentioned above. It is much more advanced and includes hundreds of tests to put a load on your system.
You can install Stress-ng in Ubuntu by running the command below:
Note that the warning mentioned above applies to this tool as well. Running stress-ng for a long time can freeze your system making it recoverable through a hard reboot only.
You can start the stress-ng test by running the command below where “cpu” refers to the number of threads used for performing the test. To stop the test anytime, close the terminal or press to make it stop.
Running the command above will run around 70 CPU tests sequentially. However, you can run all of these tests in parallel by running the command below:
It is possible to customize the command using many other command line switches, but explaining all of them here is beyond the scope of this article. You can explore these options from here.
S-tui (Stress Test Only)
S-tui is a CPU resource monitor that uses a terminal based graphical interface to display data and graphs.
It supports CPU stress testing using the Stress app listed above while giving you a nice bird’s eye view on the various CPU parameters like frequency, temperature and utilization.
S-tui can be installed in Ubuntu by running the command below:
As it is just a terminal based frontend for Stress command line app, be vary of system lock up during high usage.
Run the following command to launch it. To stop the test anytime, close the terminal or press to make it stop.
7-Zip (Benchmark Only)
7-Zip is a file compression tool that can do extreme levels of compression on files and store them in a reduced size 7z archive format. 7-Zip comes with a built-in option to run LZMA compression benchmarks for measuring CPU performance.
To install 7-Zip in Ubuntu, run command:
To run single threaded benchmark, use the command below:
Multi-threaded benchmarking can be run by using the following command:
The results are in million instructions per second (MIPS). You can compare these results with other CPU models from here.
Conclusion
These are some of the free and open source utilities that can run CPU benchmarks on your system. In the good old days, running Flash Player in Firefox was an excellent way to stress test your CPU. These days, however, all the apps mentioned above do a pretty good job.
About the author
Nitesh Kumar
I am a freelancer software developer and content writer who loves Linux, open source software and the free software community.