简体   繁体   中英

How can I get the name of the most CPU intensive application?

我特别要求OS X上的Objective-C / C解决方案。应用程序的CPU强度可以定义为它使用的CPU的百分比。

That question has a lot of answers.

If you mean "What is using the most CPU right now?", the answer is pretty much always going to be your app exactly because it is scheduled on a core to answer that question.

Which means you are really looking for an average over time. But that isn't entirely straightforward to answer, either. If you take an average over time and an app is very bursty, it may seem like it has a low % usage. If you shorten the gap, you may see some apps have artificially very high %s.

Go to a terminal window and type top -u . Then watch the fluctuations as you do stuff.

In fact, measuring the CPU usage of applications on a fully multi-tasking system is rather full of all kinds of subtle details. I would suggest looking at the source code for the top command which is likely in the "bsd utils" or "bsd commands" or like package on the Apple Open Source site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM