mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge pull request #29503 from wxy/20230524.0-⭐️⭐️-How-to-Stress-Test-CPU-in-Linux
ATRP:published/20230524.0 ⭐️⭐️ How to Stress Test CPU in Linux.md
This commit is contained in:
commit
fe513927d2
182
published/20230524.0 ⭐️⭐️ How to Stress Test CPU in Linux.md
Normal file
182
published/20230524.0 ⭐️⭐️ How to Stress Test CPU in Linux.md
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
[#]: subject: "How to Stress Test CPU in Linux"
|
||||||
|
[#]: via: "https://itsfoss.com/stress-test-cpu-linux/"
|
||||||
|
[#]: author: "Sagar Sharma https://itsfoss.com/author/sagar/"
|
||||||
|
[#]: collector: "lkxed"
|
||||||
|
[#]: translator: "ChatGPT"
|
||||||
|
[#]: reviewer: "wxy"
|
||||||
|
[#]: publisher: "wxy"
|
||||||
|
[#]: url: "https://linux.cn/article-15880-1.html"
|
||||||
|
|
||||||
|
在 Linux 中如何对 CPU 进行压力测试
|
||||||
|
======
|
||||||
|
|
||||||
|
![][0]
|
||||||
|
|
||||||
|
> 压力测试 CPU 是检查处理器在重负载下性能表现以及系统在此情况下的温度的最佳方法之一。
|
||||||
|
|
||||||
|
当你压力测试 CPU 时,可以监视系统资源,观察它们在最高工作负载下的表现。虽然性能不会改变,但如果处理器不具备良好散热能力,温度可能会影响其运作。
|
||||||
|
|
||||||
|
**对于发烧友来说,压力测试是建造新系统时必不可少的**,特别是如果你打算以后超频 CPU。
|
||||||
|
|
||||||
|
例如,在压力测试过程中,如果你的 CPU 很快变得太热,你需要通过更换 CPU 风扇、使用更好的通风机箱等方式来改进散热解决方案。
|
||||||
|
|
||||||
|
现在你已经了解到压力测试的好处,接下来我将为你介绍在 Linux 中压力测试 CPU 的以下两种方法:
|
||||||
|
|
||||||
|
- **使用 GtkStressTesting(图形界面方式)**
|
||||||
|
- **使用 stress 和 s-tui 实用程序(命令行方式)**
|
||||||
|
|
||||||
|
接下来,让我们从第一种方法开始。
|
||||||
|
|
||||||
|
### 使用图形界面方法压力测试 Linux CPU 🖥️
|
||||||
|
|
||||||
|
如果你更喜欢使用图形界面方法,而不是通过终端操作,我有一个最简单的方法来帮助你进行系统压力测试。
|
||||||
|
|
||||||
|
有一个名为 **GtkStressTesting** 的图形界面实用工具,可以帮助你进行压力测试和同时监视温度。它提供了多种预设来进行系统压力测试,并提供了选择在测试期间需要使用多少个内核的功能。
|
||||||
|
|
||||||
|
> 🚧 该工具在 [GitLab][1] 上已不再积极维护。但是它仍能按预期工作。
|
||||||
|
|
||||||
|
GtkStressTesting 可以作为 Flatpak 安装,因此如果你尚未启用 Flatpak 支持,请参考我们的 [Flatpak 安装指南][2]。
|
||||||
|
|
||||||
|
一旦你启用了 Flatpak 支持,可以通过终端(如果没有软件中心)使用以下命令来安装 GtkStressTesting 实用工具:
|
||||||
|
|
||||||
|
```
|
||||||
|
flatpak install flathub com.leinardi.gst
|
||||||
|
```
|
||||||
|
|
||||||
|
安装完成后,你可以从系统菜单中启动 GtkStressTesting 实用工具。
|
||||||
|
|
||||||
|
在这里,我建议你点击“<ruby>读取全部<rt>Read all</rt></ruby>”按钮,并输入 sudo 密码,以便工具可以获取你系统的全部信息:
|
||||||
|
|
||||||
|
![授予 GtkStressTesting 读取所有的权限][3]
|
||||||
|
|
||||||
|
从这里,你可以选择压力测试系统的时间(如果温度过高,随时可以停止进程),并在“<ruby>工作线程:自动<rt>Workers: Auto</rt></ruby>”下拉菜单中选择可用的的最大数量。
|
||||||
|
|
||||||
|
我选择了 **12 核心和 5 分钟的压力测试**:
|
||||||
|
|
||||||
|
![选择 Linux 中 CPU 压力测试的时间和核心数][4]
|
||||||
|
|
||||||
|
完成后,单击“<ruby>开始<rt>Start</rt></ruby>”按钮,监视温度,如果超过 90 度,请停止压力测试。
|
||||||
|
|
||||||
|
在我的系统上,压力测试过程中最高温度为 85 度:
|
||||||
|
|
||||||
|
![使用图形界面压力测试 Linux CPU][5]
|
||||||
|
|
||||||
|
这是一种非常简便的压力测试 CPU 的方法,是不是很简单呢? 😉
|
||||||
|
|
||||||
|
### 使用命令行终端压力测试 Linux CPU
|
||||||
|
|
||||||
|
![使用 s-tui 命令行实用程序进行压力测试][6]
|
||||||
|
|
||||||
|
使用命令行终端压力测试需要两个实用工具:[s-tui][7] 和 `stress`。
|
||||||
|
|
||||||
|
你可以从默认软件仓库或 [使用 pip][8] 来安装这些工具。如果你可以接受使用旧版本的工具,使用默认软件仓库更容易。
|
||||||
|
|
||||||
|
以下是适用于流行 Linux 发行版的安装命令:
|
||||||
|
|
||||||
|
基于 Ubuntu/Debian 的发行版:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt install s-tui stress
|
||||||
|
```
|
||||||
|
|
||||||
|
Arch Linux:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo pacman -S s-tui stress
|
||||||
|
```
|
||||||
|
|
||||||
|
Fedora/RHEL:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo dnf install s-tui stress
|
||||||
|
```
|
||||||
|
|
||||||
|
**如果想要使用 pip 安装最新版本**,可以使用以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
pip install s-tui --user
|
||||||
|
```
|
||||||
|
|
||||||
|
安装完成后,在终端中启动 `s-tui` 实用工具:
|
||||||
|
|
||||||
|
```
|
||||||
|
s-tui
|
||||||
|
```
|
||||||
|
|
||||||
|
你将会看到以下内容:
|
||||||
|
|
||||||
|
![在 Linux 中监控 CPU 的时钟速度、负荷和利用率][9]
|
||||||
|
|
||||||
|
你可以使用鼠标或键盘箭头键浏览菜单,然后点击“<ruby>压力选项<rt>Stress options</rt></ruby>”,选择你想要压力测试系统的时间(以“秒”为单位):
|
||||||
|
|
||||||
|
![设置 Linux 中 CPU 压力测试的时间长度][10]
|
||||||
|
|
||||||
|
最后,选择“<ruby>压力<rt>Stress</rt></ruby>”选项,它会在指定时间内开始压力测试:
|
||||||
|
|
||||||
|
![使用终端压力测试 Linux 中的 CPU][11]
|
||||||
|
|
||||||
|
如果温度失控,你可以点击“<ruby>退出<rt>Quit</rt></ruby>”按钮手动停止压力测试。另外,如果你想要将数据存储在 .csv 格式中,该工具也提供了相应的功能。
|
||||||
|
|
||||||
|
要存储数据,你只需要在启动 `s-tui` 实用工具时附加 `-c` 标记,如下所示:
|
||||||
|
|
||||||
|
```
|
||||||
|
s-tui -c
|
||||||
|
```
|
||||||
|
|
||||||
|
如果你想用自己喜欢的名称保存文件,则必须使用 `--csv-file` 标记,如下所示:
|
||||||
|
|
||||||
|
```
|
||||||
|
s-tui --csv-file <file 名称>.csv
|
||||||
|
```
|
||||||
|
|
||||||
|
例如,这里我将文件命名为 `Hello.scv`:
|
||||||
|
|
||||||
|
```
|
||||||
|
s-tui --csv-file Hello.scv
|
||||||
|
```
|
||||||
|
|
||||||
|
你可以在它的 [GitHub 页面][12] 上了解更多关于这个工具的信息。
|
||||||
|
|
||||||
|
### 系统快乐,人生快乐 😁
|
||||||
|
|
||||||
|
并非每个用户都意识到进行压力测试的好处。有时候它会让他们感到害怕,认为系统无缘无故地达到其极限。
|
||||||
|
|
||||||
|
但是,测试将帮助你快速评估和监视系统的状况。例如,温度异常上升和 CPU 无法处理现有负载等问题,可以帮助你及早识别硬件问题。
|
||||||
|
|
||||||
|
在任何情况下,如果你想在不进行压力测试的情况下 [保持 CPU 温度正常][13],可以参考我们提供的温度监控资源。
|
||||||
|
|
||||||
|
你还可以查看一些 Linux 的 [系统监控工具][14] 或 [htop 的替代品][15],以监控系统资源的使用情况。
|
||||||
|
|
||||||
|
💬 你对于在 Linux 中压力测试 CPU 有什么看法?你认为我们应该这样做吗?请在评论区分享你的想法。
|
||||||
|
|
||||||
|
*(题图:MJ/e5f3fc49-5e47-4f8a-8970-43a445849172)*
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://itsfoss.com/stress-test-cpu-linux/
|
||||||
|
|
||||||
|
作者:[Sagar Sharma][a]
|
||||||
|
选题:[lkxed][b]
|
||||||
|
译者:ChatGPT
|
||||||
|
校对:[wxy](https://github.com/wxy)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]: https://itsfoss.com/author/sagar/
|
||||||
|
[b]: https://github.com/lkxed/
|
||||||
|
[1]: https://gitlab.com:443/leinardi/gst
|
||||||
|
[2]: https://itsfoss.com/flatpak-guide/
|
||||||
|
[3]: https://itsfoss.com/content/images/2023/05/Allow-read-all-premissions-for-GtkStressTesting.png
|
||||||
|
[4]: https://itsfoss.com/content/images/2023/05/choose-time-and-cores-to-stress-test-the-CPU-in-linux.png
|
||||||
|
[5]: https://itsfoss.com/content/images/2023/05/stress-test-Linux-CPU-usng-GUI-1.png
|
||||||
|
[6]: https://itsfoss.com/content/images/2023/05/stress-test.gif
|
||||||
|
[7]: https://itsfoss.com/stress-terminal-ui/
|
||||||
|
[8]: https://itsfoss.com/install-pip-ubuntu/
|
||||||
|
[9]: https://itsfoss.com/content/images/2023/05/monitor-clock-speed--load-and-CPU-utilization-in-Linux.png
|
||||||
|
[10]: https://itsfoss.com/content/images/2023/05/set-time-for-how-long-to-stress-test-CPU-in-Linux.png
|
||||||
|
[11]: https://itsfoss.com/content/images/2023/05/stress-test-Linux-CPU-using-terminal.png
|
||||||
|
[12]: https://github.com:443/amanusk/s-tui
|
||||||
|
[13]: https://itsfoss.com/check-laptop-cpu-temperature-ubuntu/
|
||||||
|
[14]: https://itsfoss.com/linux-system-monitoring-tools/
|
||||||
|
[15]: https://itsfoss.com/htop-alternatives/
|
||||||
|
[0]: https://img.linux.net.cn/data/attachment/album/202306/06/155438l5oaiwow5wcmtczo.jpg
|
@ -1,183 +0,0 @@
|
|||||||
[#]: subject: "How to Stress Test CPU in Linux"
|
|
||||||
[#]: via: "https://itsfoss.com/stress-test-cpu-linux/"
|
|
||||||
[#]: author: "Sagar Sharma https://itsfoss.com/author/sagar/"
|
|
||||||
[#]: collector: "lkxed"
|
|
||||||
[#]: translator: " "
|
|
||||||
[#]: reviewer: " "
|
|
||||||
[#]: publisher: " "
|
|
||||||
[#]: url: " "
|
|
||||||
|
|
||||||
How to Stress Test CPU in Linux
|
|
||||||
======
|
|
||||||
|
|
||||||
Stress testing your CPU is one of the best ways to check your processor's performance capabilities under heavy load and the system's temperature when that happens.
|
|
||||||
|
|
||||||
When you stress test the CPU, you can monitor the system's resources to see how they behave with the CPU at its peak workload. While the performance will not change compared to what the processor is capable of, the temperature may affect its operation if it is not well-equipped.
|
|
||||||
|
|
||||||
**Stress testing is essential for enthusiasts when building a new system**, especially if you plan to overclock the CPU later.
|
|
||||||
|
|
||||||
For instance, if your CPU gets too hot too quickly during the stress test. You need a better cooling solution by changing the CPU cooler, using a better airflow cabinet, etc.
|
|
||||||
|
|
||||||
Now that you have an idea about the benefits, I will walk you through the following ways to stress test the CPU in Linux:
|
|
||||||
|
|
||||||
- **Using GtkStressTesting (GUI method)**
|
|
||||||
- **Using stress and s-tui utility (CLI method)**
|
|
||||||
|
|
||||||
So let's start with the first one.
|
|
||||||
|
|
||||||
### Stress test Linux CPU using GUI method 🖥️
|
|
||||||
|
|
||||||
If you prefer using a GUI solution over the terminal, I have just the easiest method for you to stress-test your system.
|
|
||||||
|
|
||||||
There is a GUI utility **GtkStressTesting,** which helps you stress test and monitor temperature simultaneously. It provides various presets to stress-test the system and provides an ability to choose how many cores you want to work with during the test.
|
|
||||||
|
|
||||||
🚧
|
|
||||||
|
|
||||||
This tool is no more actively maintained on
|
|
||||||
|
|
||||||
[GitLab][1]
|
|
||||||
|
|
||||||
. But it works as expected.
|
|
||||||
|
|
||||||
GtkStressTesting is available as a Flatpak, so if you haven't already enabled Flatpak support, refer to our [Flatpak setup guide][2].
|
|
||||||
|
|
||||||
Once you have enabled Flatpak support, the GtkStressTesting utility can be installed using the following via the terminal (if not software center)
|
|
||||||
|
|
||||||
```
|
|
||||||
flatpak install flathub com.leinardi.gst
|
|
||||||
```
|
|
||||||
|
|
||||||
After the installation, you can start the GtkStressTesting utility from the system menu.
|
|
||||||
|
|
||||||
Here, I would recommend you click on the `Read all` button and enter the sudo password so the utility can fetch all the information of your system:
|
|
||||||
|
|
||||||
![Allow read all premissions for GtkStressTesting][3]
|
|
||||||
|
|
||||||
From here, you can choose how long you want to stress test your system (you can always stop the process if the temp gets too high) and choose the max number available in the `Workers: Auto`.
|
|
||||||
|
|
||||||
I went for **12 cores and 5 mins of stress testing**:
|
|
||||||
|
|
||||||
![choose time and cores to stress test the CPU in linux][4]
|
|
||||||
|
|
||||||
Once you are done, click on the start button and monitor the temperatures, and if they reach beyond 90, stop the stress testing.
|
|
||||||
|
|
||||||
My system went to 85 max during stress testing:
|
|
||||||
|
|
||||||
![stress test Linux CPU usng GUI][5]
|
|
||||||
|
|
||||||
Pretty easy way to stress test the CPU. Isn't it? 😉
|
|
||||||
|
|
||||||
### Stress test Linux CPU using the Terminal
|
|
||||||
|
|
||||||
![stress test using s-tui command utility][6]
|
|
||||||
|
|
||||||
You'd need two utilities to stress test using a terminal: **[s-tui][7]** and **stress**.
|
|
||||||
|
|
||||||
You can get these tools installed from the default repositories or [using pip][8]. It is easier with default repositories if you are okay with using an older version of the tool (a tad bit).
|
|
||||||
|
|
||||||
Here are the commands that will help you install them on popular Linux distros:
|
|
||||||
|
|
||||||
**For Ubuntu/Debian base:**
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo apt install s-tui stress
|
|
||||||
```
|
|
||||||
|
|
||||||
**For Arch Linux:**
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo pacman -S s-tui stress
|
|
||||||
```
|
|
||||||
|
|
||||||
**For Fedora/RHEL:**
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo dnf install s-tui stress
|
|
||||||
```
|
|
||||||
|
|
||||||
**If you want to use pip** for the latest version, here is the command:
|
|
||||||
|
|
||||||
```
|
|
||||||
pip install s-tui --user
|
|
||||||
```
|
|
||||||
|
|
||||||
Once you are done with the installation, launch the s-tui utility in the terminal:
|
|
||||||
|
|
||||||
```
|
|
||||||
s-tui
|
|
||||||
```
|
|
||||||
|
|
||||||
And you would be met with the following:
|
|
||||||
|
|
||||||
![monitor clock speed, load and CPU utilization in Linux][9]
|
|
||||||
|
|
||||||
You can use the mouse or keyboard arrow keys to navigate through the menu, so click on the `Stres options` and choose how long you want to stress test the system **(in seconds):**
|
|
||||||
|
|
||||||
![set time for how long to stress test CPU in Linux][10]
|
|
||||||
|
|
||||||
And finally, select the `Stress` option, and it will start the stress testing for a specified period:
|
|
||||||
|
|
||||||
![stress test Linux CPU using terminal][11]
|
|
||||||
|
|
||||||
And if the temperature gets out of control, you can click on the `Quit` button to stop the stress test manually. Additionally, if you want to store the data in the `.csv` format, the tool gives you the feature.
|
|
||||||
|
|
||||||
To store the data, all you have to do is append the `-c` flag while starting the s-tui utility as shown:
|
|
||||||
|
|
||||||
```
|
|
||||||
s-tui -c
|
|
||||||
```
|
|
||||||
|
|
||||||
And if you want to save the file with a name to your liking, you'd have to use the `--csv-file` flag as shown:
|
|
||||||
|
|
||||||
```
|
|
||||||
s-tui --csv-file <name of file>.csv
|
|
||||||
```
|
|
||||||
|
|
||||||
For example, here, I named the file `Hello.scv`:
|
|
||||||
|
|
||||||
```
|
|
||||||
s-tui --csv-file Hello.scv
|
|
||||||
```
|
|
||||||
|
|
||||||
You can explore more about the tool on its [GitHub page][12].
|
|
||||||
|
|
||||||
### Happy System, Happy Life 😁
|
|
||||||
|
|
||||||
Not every user realizes the benefits of a stress test. Sometimes it scares them off with the idea of their system reaching its limits for no reason.
|
|
||||||
|
|
||||||
However, the test will help you quickly evaluate and monitor your system's condition. Things like **abnormal temperature spikes** and CPU being unable to handle what it is should help you identify hardware issues early on.
|
|
||||||
|
|
||||||
In either case, you can refer to our temperature monitoring resource if you want to [keep your CPU monitor in check][13] without performing stress tests.
|
|
||||||
|
|
||||||
You can also check out some of the [system monitoring tools][14] or [htop alternatives][15] for Linux to keep an eye on your system resources.
|
|
||||||
|
|
||||||
💬 _What do you think about stress testing your CPU in Linux? Do you think we should do it? Share your thoughts on it in the comments below._
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://itsfoss.com/stress-test-cpu-linux/
|
|
||||||
|
|
||||||
作者:[Sagar Sharma][a]
|
|
||||||
选题:[lkxed][b]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]: https://itsfoss.com/author/sagar/
|
|
||||||
[b]: https://github.com/lkxed/
|
|
||||||
[1]: https://gitlab.com:443/leinardi/gst
|
|
||||||
[2]: https://itsfoss.com/flatpak-guide/
|
|
||||||
[3]: https://itsfoss.com/content/images/2023/05/Allow-read-all-premissions-for-GtkStressTesting.png
|
|
||||||
[4]: https://itsfoss.com/content/images/2023/05/choose-time-and-cores-to-stress-test-the-CPU-in-linux.png
|
|
||||||
[5]: https://itsfoss.com/content/images/2023/05/stress-test-Linux-CPU-usng-GUI-1.png
|
|
||||||
[6]: https://itsfoss.com/content/images/2023/05/stress-test.gif
|
|
||||||
[7]: https://itsfoss.com/stress-terminal-ui/
|
|
||||||
[8]: https://itsfoss.com/install-pip-ubuntu/
|
|
||||||
[9]: https://itsfoss.com/content/images/2023/05/monitor-clock-speed--load-and-CPU-utilization-in-Linux.png
|
|
||||||
[10]: https://itsfoss.com/content/images/2023/05/set-time-for-how-long-to-stress-test-CPU-in-Linux.png
|
|
||||||
[11]: https://itsfoss.com/content/images/2023/05/stress-test-Linux-CPU-using-terminal.png
|
|
||||||
[12]: https://github.com:443/amanusk/s-tui
|
|
||||||
[13]: https://itsfoss.com/check-laptop-cpu-temperature-ubuntu/
|
|
||||||
[14]: https://itsfoss.com/linux-system-monitoring-tools/
|
|
||||||
[15]: https://itsfoss.com/htop-alternatives/
|
|
Loading…
Reference in New Issue
Block a user