如何尽可能地增加我的CPU使用率 [英] How can increase my CPU usage as much as possible

查看:91
本文介绍了如何尽可能地增加我的CPU使用率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我编写了一个处理大量变量的应用程序,因此完成它的工作需要花费大量时间,如果有任何方法,我只需要大约25%的CPU。将它增加到%80或更多。

谢谢

Hi I wrote an application that is processing on a lot of variables so it takes a hole lot of time to finish it's job and only takes about %25 of my CPU i wounder if there's any way that i can increase it up to %80 or more.
thanks

推荐答案

你可能有一个四核系统:所以一个线程平稳运行只能使用最多25%的可用CPU资源。要增加并使用更多内核,您必须将任务分成4个块并将每个块移动到单独的线程中。请参阅 BackgroundWorker类 [ ^ ]这是一个简单的方法。
The chances are that you have a four-core system: so one thread running flat out will only ever be able to use a maximum of 25% of your available CPU resources. To increase that and use further cores, you would have to break your task into 4 "chunks" and move each chunk to a separate thread. See the BackgroundWorker Class[^] for a simple way to do this.


要添加到OriginalGriff的答案,我更喜欢使用任务 [ ^ ]而不是Backgroundworker。主要是因为使用任务让你处理更复杂的情况。



你可以阅读这两个类的差异,例如http://blog.stephencleary.com/2013/05/taskrun-vs-backgroundworker-intro.html [ ^ ]
To add to OriginalGriff's answer, I would prefer using Task[^] instead of Backgroundworker. Mainly because using tasks let's you handle more complicated situations.

You can read about the differences for both classes for example from http://blog.stephencleary.com/2013/05/taskrun-vs-backgroundworker-intro.html[^]


这篇关于如何尽可能地增加我的CPU使用率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆