Stress test cpu in linux. Working with Phoronix Test Suite, or how to test the performance of virtual machines in Linux? File permission attributes include

Monitoring is carried out using a set of programs lm-sensors.


aptitude install lm-sensors

You can take sensor readings with the command:


sensors

Real-time temperature monitoring is performed by the following command:


watch sensors

The output of the command contains information about voltage, fan speed, processor temperature (each core separately), temperature hard drives. An important indicator is the maximum recorded temperature value (field high in core temperature readings). You can monitor only the temperature of the processor with the command:


while (true) do date; sensors | grep core; echo "======"; sleep 1s; done

There are also various graphical utilities for displaying readings. lm-sensors. For GNOME easy to use applet GNOME Sensors Applet.

CPU stress testing

Plastic bag cpuburn

Checking the operation of video card drivers

Check for 3D acceleration:


glxinfo | grep OpenGL

The output should be like this:


OpenGL vendor string: Tungsten Graphics, Inc OpenGL renderer string: Mesa DRI Intel(R) G33 GEM 20100330 DEVELOPMENT OpenGL version string: 1.4 Mesa 7.10-devel OpenGL extensions:

Let's check the support for 3D acceleration by means of the video card:


glxinfo | grep direct

If 3D support is implemented, the output will be:


direct rendering: Yes

Let's check the speed of 3D:


glxgears

A window will appear with a simple 3D animation. In this case, information about the rendering speed will be displayed in the console every 5 seconds. Normal FPS values ​​for a configured driver should be above 1000 on average (if V-sync is enabled, the FPS value will be capped by the sync frequency).

Another OpenGL test:


/usr/lib/xscreensaver/glblur-fps

A screensaver window will appear showing the FPS value.

In case of any problems, you can reinstall the video driver (for integrated Intel graphics, you need to reinstall the package xserver-xorg-video-intel). Driver settings are carried out by the program driconf. Also, to control the operation of the Intel video card, you can install the package intel-gpu-tools(the package includes the intel_gpu_top utility, which allows you to monitor the video processor load in real time).

System Performance Testing

phoronix-test-suite package

Performance testing is carried out by the program phoronix-test-suite. It is a software shell that allows you to automatically download and run various testing programs, collect and store data on test results.

Let's install the program:


aptitude install phoronix-test-suite

View a list of all available tests with their brief description can be done with the following command:


phoronix-test-suite list-tests

The tests are run with the command:


phoronix-test-suite benchmark TEST_NAME

  • CPU:

    • c-ray- multi-threaded math test. High load on the processor. Result on C2D 2.0: 387.55 seconds.

    • build-linux-kernel- assembly of the Linux kernel. Long test. Evenly loads the processor and memory (uses gcc).

    • scimark2- powerful single-threaded test (intensive scientific computing). Shows the performance of a single core in gigaflops.

    • ffmpeg- video encoding (test files occupy 130MB). On C2D 2.0: 25.99 seconds.


  • Memory:

    • ramspeed- memory test. Average CPU load. Results DDR2-800 2Gb (copy,int) : 2280.10 MB/s.

    • stream- shows the memory speed in various operations.


  • HDD:

    • iozone- test hard drive. Shows the read and write speed for blocks of various lengths. Result WD 80Gb (W,4K,512M): 52.42 MB/s.


  • Graphic arts:

    • gtkperf- testing various elements of the GNOME GUI.

    • unigine-tropics- beautiful 3D benchmark, you need customized drivers with support for 3D acceleration.


For long-term diverse testing, it is recommended build-linux-kernel. For short stress testing c-ray(along with the program

question computer diagnostics owners of PCs or laptops are usually puzzled by regular errors in their work. But a considerable proportion of enthusiasts are fond of overclocking processors, video cards, overestimating the operating frequencies of the memory, etc. Naturally, uninterrupted operation in such emergency situations is not guaranteed, and overclockers in the process of overclocking have to check the stability of the overclocked device. Processor check- a mandatory step when overclocking the CPU. The proposed article is just devoted to the issue of checking the operation of the processor under maximum load after acceleration. Utility LinX 0.6 with very simple interface help us with this.

Recently, the site had an article about, which only mentioned the need for CPU diagnostics, but there was no explanation. Today I decided to fill this gap and describe the procedure for checking the processor. For computer diagnostics you need only one utility designed for maximum CPU load with computing tasks. The name of this compact program is LinX. At the moment, the current one is LinX 0.6.5". In addition to stability testing, the utility can also be used as a good benchmark.

User Perspective LinX 0.6 very simple and convenient thing with a simple and intuitive interface (Russian and English versions). It supports both Intel and AMD CPUs. In the settings, you can select the 32/64-bit operating mode, the number of threads, enable or disable Intel's HyperThreading technology, set the number of runs, monitor the progress of testing "live" ... Automatic saving of set processor test parameters will allow testing with the same settings on subsequent launches, for example, when gradually overclocking the CPU.


The interface of the main program window contains only a few controls. First of all, we are interested in the parameters "Memory" / "Memory" and the number of runs "Number of times" / "Run". For computer diagnostics it is recommended to select all available memory in the first parameter (the “All” button next to “Memory”), and set the “Number of times” / “Run” empirically: run one run, and calculate the required number of runs for the program to work for at least an hour. In the "Settings" / "Settings" menu, select the 32/64 bit mode depending on the installed processor and operating system version. To start/stop the test, use the "Test"/"Stop" buttons ("Start"/"Stop"). During the test, the test progress indicator will display the time elapsed since the start, and when the last pass is completed, it will display the inscription “Completed without errors in MM m SS s” (or “Finished without errors in MM m SS s” in the English version of the interface).

When testing an unstable system for a long time, errors may occur. The "Stop on Error" item in the Linx 0.6 settings will stop further checking of the processor. This can be quite useful when errors occur due to cpu overheating. A timely stopped test may in some cases save a life to the tested CPU. If, after starting the utility, you recorded a temperature close to critical or exceeding it, then this is a clear signal that you need to replace cooler or reduce acceleration.

Using LinX 0.6.5 as benchmark processor performance results will be displayed in the column "GFlops" / "GFlops" of the final table of the main program window. Yes, for Intel Core i7-3770k, which was overclocked to 4.5 GHz, the result will be a figure in the region 110…115 GFlops depending on settings. after several runs, the specified CPU is placed higher: the speed is indicated in the table for each pass and the status line contains information about the peak (maximum) performance in GFlops.

By the way, if you are wondering CPU overclock, then be puzzled by the expediency of including technology hyperthreading for Intel CPU. By no means in all tasks from HT there is a speed increase, but the included HT underestimates the overclocking capabilities of the "stone" very often. Judging by the numerous reviews, there is not the slightest increase in FPS from HyperThreading in most games - here the “playability” is more dependent on the video card.

Benchmark is a measurement of the maximum performance of a computer, which is expressed in conventional points. Thanks to this, you can compare the performance of different computers, or the same computer after, for example, overclocking or undervolting.

Benchmark and stress test are not the same thing. Both during the benchmark and during the stress test, the system receives a full load. But the main goal of benchmarking is to evaluate performance, and the main goal of a stress test is to check whether the system can operate at its limit of workload, or determine this limit. Although, in fact, some programs combine both functions.

The benchmark can be performed for the system as a whole, or for its individual components: for the central processor, video card, I / O system.

Linux has several programs for evaluating CPU performance, for example: sysbench, stress-ng And phoronix-test-suite. Of them stress-ng primarily performs the functions of a stress test, but it displays the resulting metrics, so it is quite suitable for evaluating and comparing system performance.

Benchmark in sysbench

sysbench is a utility command line. It was created to evaluate the performance of servers with heavily loaded DBMS, but is also suitable for benchmarking conventional systems.

Installation on Ubuntu, Linux Mint, Debian, Kali Linux:

sudo apt install sysbench

Built-in tests:

  • fileio- File I/O testing
  • cpu- CPU performance testing
  • memory- Testing the speed of memory functions
  • threads- Testing the performance of the thread subsystem
  • mutex- Mutex performance test

To run a CPU performance test:

Sysbench cpu run

Pay attention to how the program starts: at the beginning there is the name of the test, then the options (there are none in the first example), and then the command.

The program has two execution aisles:

  • 10000 operations with numbers
  • 10 seconds execution

Depending on what comes first, the program will exit either after 10,000 events or after 10 seconds.

Modern processors are very productive and if the program is completed very quickly, then the data can be distorted. For example, when evaluating processor performance, for example, throttling (frequency reset) plays a role. Throttling starts due to overheating or exceeding TDP. These effects are observed only at long distances of the processor. If, for example, the test completed in a second and you got n processed operations, this does not mean that the processor in 60 seconds will execute 60*n operations, since it will drop frequencies due to overheating and exceeding the heat dissipation limits set in TDP.

For a longer test run, use the options --cpu-max-prime And -time. The first sets the maximum number of operations performed, and the second sets the maximum benchmark time. When options are used at the same time, priority is given to -time.

Modern CPUs are multi-core and multi-threaded:

Default sysbench runs in one thread. Therefore, if you want to use all the cores of your processor, use the option --threads. I have 6 physical and 12 logical CPU cores, so I'll use 12 to make sure all CPUs work.

When using the option --cpu-max-prime, the shorter the program completion time, the more productive the central processor:

Sysbench cpu --threads=12 --cpu-max-prime=100000 run

The program completed the work too quickly - in 10 seconds it is unlikely that the processor had time to undergo serious throttling. Therefore, with these values, the test is suitable for evaluating peak performance over a short distance.

Results obtained:

CPU speed: events per second: 538.23 General statistics: total time: 10.0188s total number of events: 5393 Latency (ms): min: 19.85 avg: 22.27 max: 30.56 95th percentile: 23.10 sum: 120125.61 Threads fairness: events (avg/ stddev): 449.4167/4.11 execution time (avg/stddev): 10.0105/0.01

CPU speed events per second means the number of operations performed in the central processor per second - the higher the value, the more productive the system.

General statistics total time means the total execution time of the operations.

General statistics total number of events means the total number of completed events.

If the system shuts down too quickly, you can increase the value, for example, to two hundred thousand events:

Sysbench cpu --cpu-max-prime=200000 run

Another way to check for throttling and assess CPU performance under sustained load is to set the execution time, in the example below, the time is set to 300 seconds.

Sysbench cpu --threads=12 --time=300 run

I have when using options -time And --cpu-max-prime CPU speed events per second differ by dozens of times - apparently either some kind of bug in the program, or the program calculates according to some other rules.

Benchmark in phoronix-test-suite

Install the program:

Sudo apt install phoronix-test-suite

Run - for the first time you will need to accept the license agreement, so the program will ask permission to send anonymous statistics:

Phoronix-test-suite list-available-suites

The previous command will list the available benchmarks.

Available test suites in Phoronix Test Suite v8.0.1

Pts/audio-encoding - Audio Encoding System pts/chess - Chess Test Suite Processor pts/compilation - Timed Code Compilation Processor pts/compiler - Compiler Processor pts/compression - Timed File Compression Processor pts/computational - Computational Test Suite System pts/computational -biology - Computational Biology Test Suite Processor pts/cpu - CPU / Processor Suite Processor pts/cryptography - Cryptography Processor pts/daily-kernel-tracker - Daily Kernel Tracker System pts/daily-system-tracker - Daily System Tracker System pts/database - Database Test Suite System pts/desktop-graphics - Desktop Graphics System pts/disk - Disk Test Suite Disk pts/encoding - Encoding System pts/favorites - Favorites System * pts/gaming - Gaming System pts/gaming-closed - Closed-Source Gaming System * pts/gaming-free - Free Software Gaming System pts/gui-toolkits - GUI Toolkits Graphics pts/ioquake3-games - Games Using The ioquake3 Engine System pts/iqc - Image Quality Comparison Suite Graphics pts/java - Java System pts /java-opengl - Java OpenGL System pts/kernel - Kernel System pts/linux-system - Linux System System pts/machine-learning - Machine Learning System pts/memory - Memory Test Suite Memory pts/mesa - Mesa Test Suite Graphics pts/ motherboard - Motherboard System pts/multicore - Multi-Core Processor pts/netbook - Netbook Test Suite System pts/network - Networking Test Suite Network pts/nevada - OpenSolaris Nevada Test Suite System pts/opencl - OpenCL System pts/opengl-demos - OpenGL Demos Test Suite System pts/opengl-workstation - OpenGL Workstation Test Suite System pts/pts-desktop-live - PTS Desktop Live System pts/ray-tracing - Ray-Tracing Test Suite System pts/server - Server Motherboard System pts/ue4 - Unreal Engine 4 Tech Demos On Linux Graphics pts/universe - Unigine Test Suite Graphics * pts/universe - Universe Test Suite System pts/universe-cli - Universe CLI Test Suite System * pts/universe-x - Universe X Test Suite System pts/ video-encoding - Video Encoding System pts/workstation - Workstation System pts/workstation-graphics - Workstation Graphics Graphics pts/xrender - X Render Extension Testing Graphics system/collection - Collection System

Partially supported sets are marked with an asterisk.

To run the CPU performance evaluation run:

Phoronix-test-suite run pts/cpu

Please note that pts/cpu and other benchmarks take up several gigabytes of disk space. For example, pts/cpu will download about 3 GB of data and use about 7 GB of disk space (in the user's home directory).

For information on how to monitor the current frequency and temperature of the processor in Linux, see.

I ran the Linpack test and thought: is it time for me to change the thermal paste on my laptop?

Yes, according to the results of several tests in a row (I will not clutter up the article with pictures), it is clear that the processor goes into throttling (skipping cycles and resetting the frequency when heated), but how quickly does it start doing this?

CPU stress test in Linux terminal

Having asked this question and searched the Internet for utilities, I realized that the main problem in solving the task I set was the simultaneous launch of at least a couple of utilities and wide eyes in two windows ... And I came to the conclusion that the console version is more suitable for me, rather than multi-colored windows of open programs.

I started with sysbench:

sudo apt install sysbench

sysbench --num-threads=4 --test=cpu --cpu-max-prime=100000 run

  • --num-threads=4- this is the number of threads, I have a dual-core four-thread Intel® Core ™ i7-640M, so 4;
  • --cpu-max-prime=100000- this is the maximum number of operations performed, I set it to 100000, because default is 10000, ending the test too soon.

Then I switched to Linpack. Since I have a processor from Intel and I have a certain amount of laziness (laziness is the engine of progress), I took, downloaded and unpacked the ready-made Intel Linpack, after creating the linpack directory in my home directory:

mkdir ./linpack
cd ./linpack
wget http://registrationcenter-download.intel.com/akdlm/irc_nas/9752/l_mklb_p_2018.3.011.tgz
tar -xvzf ./l_mklb_p_2018.3.011.tgz

For AMD processors, I would not try this option, since the compiler from Intel inserts bookmarks that check the processor, and if it is not Intel ... well, think about a hundred or two extra instructions, the processor will execute and obviously lose performance. For AMD it's better to build Linpack from sources like these . In this article, I will not consider building from sources - read the README in the source code.

Let's get back to Intel's Linpack. There is a lot of extra stuff and I don’t need it, but what I need to consider regarding version 2018.3.011. I will immediately go to the desired directory, so as not to type long commands later:

cd ./l_mklb_p_2018.3.011/benchmarks_2018/linux/mkl/benchmarks/linpack

Since, by default, Intel's Linpack is designed for testing server Xeons, let's create our own file that will be used as input options - just reduce the number of tests, otherwise we'll get tired of "a couple of days" waiting for the test to complete. I have Linux Mint LMDE 3, so I use the xed text editor, and I like it for more functionality, especially when I run it as root - it changes color to red. And so, we create in the same directory that we moved to, a file, for example, my_test:

And copy the following content into the created file:

Shared-memory version of Intel(R) Distribution for LINPACK* Benchmark. *Other names and brands may be claimed as the property of others.
Sample data file lininput_xeon64.
5 # number of tests
1000 2000 5000 10000 20000 # problem sizes
1000 2000 5008 10000 20000 # leading dimensions
4 2 2 2 1 # times to run a test
4 4 4 4 4 # alignment values ​​(in KBytes)

Well, actually launching Linpack with the created file:

./xlinpack_xeon64 -i ./my_test

./xlinpack_xeon64 ./my_test

You can also use stress-ng or stress, but this still does not solve the problem I set. These utilities do not show me the output of temperature, frequencies and time from the start.

The temperature can be shown by sensors - more about installing this utility. And this utility will be needed in the further consideration of my question. Linux is great and powerful: the same task can be solved in different ways. I was too lazy to take on C, and I wrote the missing part for me in BASH, because there were not so many lines. Without sensors installed, my script will not work. Naturally, I did not write the fixation of throttling - it will be visible by resetting the frequency and temperature anyway. Here is the script itself:

#!/bin/bash
out=0 # test process control variable
pid_test="tty" # PID of the test process (made an existing directory to run without arguments)
cpus_num=$(cat /proc/cpuinfo | grep -ci "processor") # number of processors/cores/threads
echo -en "\033[?25l" 1>&2 # hide cursor
echo -en "\033[^:]*: //g" | sort -u # output processor model
echo -en "\033=$(sensors | sed "/Core ""$i""/!d;s/.*crit = +\(.*\)[.]°C).*/\1/ ")
if [ -n "$(cpu_crit_temp[i])" ]
then
let cpu_red_temp[i]=cpu_crit_temp[i]-10
let cpu_yel_temp[i]=cpu_crit_temp[i]-30
cpu_min_temp[$i]=1000
cpu_max_temp[$i]=0
fi
done
start_time=$(cat /proc/uptime | sed "s/[.] .*$//") # start time
if [ -n "$1" ]
then
script_pid="$$"
(if ! $@ > "$0_out" 2>&1 # run test file
then
kill -s SIGABRT $script_pid # signal the main script to fail to run
fi 2>/dev/null)&
pid_test="$!" # PID of the test process
fi
while (true) # temperature control
do
for ((i=0; i<$cpus_num; i++))
do
cpu_freq[$i]=$(cat /sys/devices/system/cpu/cpu$(i)/cpufreq/scaling_cur_freq | sed "s/...$//")
cpu_temp[$i]=$(sensors | sed "/Core ""$i""/!d;s/.*+\(.*\)[.]°C[ \t]*(.*/\ 1/")
if [ -n "$(cpu_temp[i])" ]
then
(($(cpu_temp[i])< ${cpu_min_temp[i]})) && cpu_min_temp[$i]=${cpu_temp[i]}
if (($(cpu_temp[i]) > $(cpu_max_temp[i])))
then
cpu_max_temp[$i]=$(cpu_temp[i])
time_max[$i]=$(cat /proc/uptime | sed "s/[.] .*$//")
let time_max[i]=time_max[i]-start_time
fi
if (($(cpu_temp[i]) > $(cpu_red_temp[i])))
then
echo -en "cpu$(i):\t"
echo -en "\033)"
echo -en "\033)"
echo -en "\033)"
echo -en "\033) > $(cpu_yel_temp[i])))
then
echo -en "cpu$(i):\t"
echo -en "\033)"
echo -en "\033)"
echo -en "\033)°C; max: "
echo -en "\033)"
echo -en "\033)sec)"
else
echo -en "cpu$(i):\t"
echo -en "\033)"
echo -en "\033)"
echo -en "\033)°C; max: "
echo -en "\033)"
echo -en "\033)sec)"
fi
else
echo -en "cpu$(i):\t"
echo -en "\033)"
echo -en "\033 .*$//")
let time=time-start_time
echo -en "Time:\t$time sec."
[ ! -d "/proc/$(pid_test)" ] && break # exit when test is over ( The best way control via comm and cmdline, but... too lazy)
[ "$out" != "0" ] && break # exit on test failure
echo -en "\033[$(i)A\r" 1>&2 # move cursor up $i lines and to start of line
sleep 0.1 # pause so that the frequency output does not jump much
done
echo ""
echo -en "\033[?25h" 1>&2 # enable cursor
if [[ "$out" == "0" && -n "$1" ]]
then

rm -fR "$0_out"
exit 0
elif [[ "$out" == "1" && -n "$1" ]]
then
kill -9 "$pid_test" 1>/dev/null 2>/dev/null
cat "$0_out" | sed "/^$/d;/Sample data/d;/CPU frequency/d;/Parameters are set/,/Data alignment value/d"
rm -fR "$0_out"
exit 1
elif[ "$out" == "1" ]
then exit 1
elif[ "$out" == "2" ]
then
echo -en "\033)

mob_info