How to stress your CPU in Linux


A key matrix in determining the vitality of a Linux distribution, or the hardware it runs on, is system performance. Depending on your goal, you can choose from a variety of dedicated tools to monitor different components such as processor frequency, temperature, and memory usage. But if you prefer CLI, like us, you will rather enjoy working with S-TUI.

With S-TUI, which stands for Stress-Terminal UI, you can simultaneously monitor temperature, frequency, power and CPU usage. The utility presents all the information in graphical form and can even be used to export the data to CSV files. Better yet, you can configure S-TUI to automatically launch scripts when the values ​​of any of the monitored components exceed the set threshold values. When paired with stress, another command line utility, S-TUI can also be used to test your system under stress.

Installing S-TUI

Although S-TUI is not available in the software repositories of the most popular desktop distributions, installing the tool is fairly straightforward and the the project’s GitHub page describes various installation techniques. For our installation, we will be using Ubuntu 21.04.

1. In the terminal, Update the available software repositories and install the Python 3 packaging tool.

$ sudo apt update
$ sudo apt install python3-pip

2. Install S-TUI using pip3.

$ sudo pip install s-tui

3. Run S-TUI.

$ s-tui

Unlike many other command line utilities, S-TUI does not require any configuration and you can start using it immediately after installation.

Using S-TUI

At the top of the sidebar on the left are your processor details. Our Lenovo test machine was correctly identified as running an Intel Core i3-5005U 2.00 GHz processor. This is because S-TUI uses various other native tools and utilities to collect the relevant information. For example, the same information and many more details can be obtained by running the cat / proc / cpuinfo command.

When you launch S-TUI for the first time, it displays all four parameters – Frequency, Usage, Temperature, and Power – and refreshes the data every two seconds.

(Image credit: Avenir)

To change the refresh rate from two seconds to 0.1, change the value of Refresh[s]: 2.0 on the sidebar at 0.1, note that this will put extra strain on your Pi.

Use the up and down arrow keys to navigate the sidebar, but S-TUI also supports using H and J to scroll, much like you would in Vim. S-TUI will also work with the mouse.

Use S-TUI to test your machine under stress

By default, S-TUI is configured to only monitor your system. To push our machine to its limits, we installed “stress” a terminal stress test tool. Stress works with all types of processors, we use it to test Raspberry Pis stress as part of the Stressberry Python benchmarking tool.

1. To install stress, open a terminal and enter the following.

$ sudo apt install stress

2. Open S-TUI.

$ s-tui

3. Using the arrow keys, navigate to Stress and press the space bar. Alternatively, you can also use the mouse to select. You will see the processor graphics update quickly, showing the current processor temperature, frequency, and usage. The stress test will run indefinitely.

Test your CPU in Linux

(Image credit: Avenir)

4. Deactivate stress test by navigating to Monitor and pressing the space bar, or clicking with your mouse.

5. To define a time-limited stress test, navigate / click on Constraint options and change the timeout to the desired time (in seconds). Set the number of Sqrt () workers to match the number of cores in your processor. Click Save when finished.

Test your CPU in Linux

(Image credit: Avenir)

6. Click on / navigate to Stress and press the space bar to run the timed test. Here we have set the duration to 30 seconds and left the number of workers at 4.

Test your CPU in Linux

(Image credit: Avenir)

Saving your test results

The collected data is lost as soon as you exit S-TUI, because the tool does not save it by default.

To automatically save the collected information to a time-stamped CSV file when you exit S-TUI, invoke the command as well.

$ s-tui -c

To specify your own filename, invoke the command with a “–csv-file” supply a filename.

$ s-tui --csv-file .csv

If you prefer your data in JSON format, then we can output the data in JSON format, but only the current state, not a running log.

$ s-tui -j

(Image credit: Avenir)

Source link

Leave A Reply

Your email address will not be published.