在Android的线程性能 [英] Thread Performance in Android
问题描述
有什么办法来监控Android手机上线程的性能。
Is there any way to monitor the performance of a thread on Android phone.
正如在任何POSIX库?
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.
感谢你。
推荐答案
Linux支持每个线程的CPU使用率计时器。时代的进步,当一个线程执行或(我认为)阻塞的磁盘I / O,但是当其他线程正在执行或当前线程等待一个事件不前进(例如的Object.wait())。
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()).
您可以通过调用使用它从Android应用 SystemClock.currentThreadTimeMillis()
。在NDK C / C ++ code,您可以使用POSIX API clock_gettime(CLOCK_THREAD_CPUTIME_ID)
。
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)
.
这篇关于在Android的线程性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!