需要一个能让CPU 100%运行的程序
我需要一个程序,可以让我的 CPU 100% 运行。
最好是用 C 语言编写一个小程序,它将使 CPU 以 100% 的速度运行,并且一个程序没有被编译器“优化”,因此它什么也不做。
建议?
I need a program, that will make my CPU run at 100%.
Preferably in C, a tiny program, that will make the CPU run at 100%, and one, that is not "optimized" by the compiler, so it does nothing.
Suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
或者,如果您有一个多核处理器 - 未经测试......就像上面的一样:)
Or, if you have a multi-core processor -- untested ... just like the one above :)
这个呢:
What about this one:
这是一个很好的老式叉子炸弹。
Here's a good, old-fashioned fork bomb.
将其复制并粘贴到名为
source.c
的文件中:编译
source.c
:gcc source.c -o myprogram
运行它:
./我的程序
Copy and paste this in a file named
source.c
:Compile
source.c
:gcc source.c -o myprogram
Run it:
./myprogram
建议空循环的答案只能使双核 CPU 达到 50%,四核 CPU 达到 25% 等。
因此,如果这是一个问题,可以使用类似的东西
The answers suggesting an empty loop shall only bring dual core CPU to 50%, quad-core to 25% etc.
So if that is an issue one can use something like
适用于多线程系统的本机 Windows 解决方案。在 Visual C++(或 Visual Studio)上编译,无需任何库。
Native Windows solution for multithreaded systems. Compiles on Visual C++ (or Visual Studio) without any library.