Calculate CPU usage for iOS

I have recently needed to monitor how much CPU is used by a graphics-intensive app I am developing. Instruments is a wonderful tool to find out performance bottlenecks in your code, but in many cases simply monitoring cpu usage allows for an easier way to find out what is going on (possibly in an unexpected way) in your app.

Collecting this kind of information requires getting to the mach-subsystem but in the end it is not so difficult to set up. Much of the information I needed to accomplish this came from the extremely interesting, though not 100% up-to-date, Mac OS Internals: A Systems Approach, by Amit Sing.

You can find the code on my github.

Copyright © Labs Ramblings

Built on Notes Blog by TDH
Powered by WordPress

That's it - back to the top of page!