fdh
fdh

Reputation: 5344

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

I am specifically asking for an Objective-C/C solution on OS X. The CPU Intensity of an application can be defined as the percentage of the CPU it uses.

Upvotes: 0

Views: 243

Answers (1)

bbum
bbum

Reputation: 162712

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.

Upvotes: 2

Related Questions