Getting CPU usage of a specific process on iOS4
I am trying to get CPU 开发者_JAVA技巧usage of various processes (cpu ticks) from a background application running on iOS4 using Apple SDK. This is done completely with users' consents so there is nothing unethical here.
I have used sysctl to get process list but the cpu ticks for the process is always returned as 0 from the device. Alternatively, I tried to look for foreground process and polling every few seconds to get application usage that way. However, there is no API/flag which indicates if a process is running in the foreground or background. I event checked for getting memory consumption of a process and to figure out if it was running in the background (memory will not fluctuate if in the background). However, the API, proc_pidinfo, is private and Apple rejected the app.
I have seen some posts related to such topics but did not get a definite answer.
I am aware sand boxing will not allow to get info on other apps (which is, btw, not true since sysctl gives PIDs, process names and start time). However, I saw an application on the appstore called MyLife by Zokem and they report such information. They are accurate to the second. I was wondering if there is a system log or DB which stores this information.
Anyone has ideas about getting the usage time of applications?
精彩评论