I'd like to measure the FPS (refresh rate) of a certain Android View which uses TextureView. To do this, I need some way to measure FPS programmatically (e.g. not using ADB.exe and not using third party apps or tools).
I have seen this question but it does not answer where to log frame time.
Is there an API within Android to get an event when the screen refreshes or is composed? Using this it would be relatively simple to measure frame time and hence calculate FPS.
Same question for CPU usage. Any or all APIs to measure performance appreciated!
Well, it looks like TinyDancer can do what you want:
//you can add a callback to get frame times and the calculated
//number of dropped frames within that window
TinyDancer.create()
.addFrameDataCallback(new FrameDataCallback() {
@Override
public void doFrame(long previousFrameNS, long currentFrameNS, int droppedFrames) {
//collect your stats here
}
})
.show(this);
}
If you need to know the CPU usage you can always use top
. Smth like this:
root@android:/data # top -n 1 -s cpu
User 28%, System 29%, IOW 0%, IRQ 0%
User 189 + Nice 162 + Sys 355 + Idle 509 + IOW 0 + IRQ 0 + SIRQ 2 = 1217
PID PR CPU% S #THR VSS RSS PCY UID Name
31096 0 20% S 20 463368K 78884K fg u0_i77 com.android.chrome:sandboxed_process0
29042 1 11% S 54 451036K 84876K fg u0_a10 com.android.chrome
130 2 9% S 25 79228K 37136K fg system /system/bin/surfaceflinger
...
...
...
Calling system command from Android app is not difficult.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With