开发者

Thread Performance in Android

开发者 https://www.devze.com 2023-01-13 04:19 出处:网络
Is there any way to monitor the performance of a thread on Android phone. As in any POSIX library开发者_开发技巧?

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消