从 iOS 上的应用程序获取 CPU 使用率
如何获取应用程序的 CPU 使用率?这绝对是可能的,因为应用程序商店中有应用程序( Activity Monitor Touch)可以显示它。
How do I obtain CPU usage for an application? It's definitely possible, because there are application in App store (Activity Monitor Touch) which can show it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更新。此代码对我有用:
更新 2。 thread_list 泄漏,因此添加了 vm_deallocate
Update. This code is working for me:
Update 2. The thread_list was leaking, so added vm_deallocate
对于斯威夫特 3:
For Swift 3:
试试这个:
但是,该方法根据每个进程的起点计算百分比。如果您正在寻找计算这些数字的更传统方法,请参阅 Petesh 的回答。
Try this:
However, that method calculates the percentages based on the starting point of each process. If you are looking for the more traditional way of calculating these numbers, see Petesh's answer.