Thread Performance in Android
Is there any way to monitor the performance of a thread on Android phone.
As in any POSIX library开发者_开发技巧?
I want to find the time taken by a "thread" during execution, while many other applications might also be running.
Thank You.
Linux supports a per-thread CPU usage timer. Time advances when a thread is executing or (I think) blocked on disk I/O, but does not advance when other threads are executing or the current thread is waiting for an event (e.g. Object.wait()).
You can use it from an Android app by calling SystemClock.currentThreadTimeMillis()
. In C/C++ code in the NDK, you can use the POSIX API clock_gettime(CLOCK_THREAD_CPUTIME_ID)
.
精彩评论