Anyone having any idea about how to get FPS(frame per second) of android device ?
There is an option in development settings to display FPS, but I want to write an app to do the same.
It internally calls surfaceflinger
api.
To calculate frames per second, you just take the number of rendered frames and divide it by the seconds passed.
By far, the simplest and easiest way to measure FPS on Android is to use the GameBench Android or Desktop App. GameBench takes care of querying the correct OS services and returns the FPS value.
Traditionally, most devices have supported only a single display refresh rate, typically 60Hz, but this has been changing. Many devices now support additional refresh rates such as 90Hz or 120Hz. Some devices support seamless refresh rate switches, while others briefly show a black screen, usually lasting a second.
In your main Activity
class override the onDraw()
method. Invoke super.onDraw()
then store the current system time. Calculate the delta_time
in ms between the current call to draw and the previous call to draw. Then calculate FPS using 1000 ms / delta_time ~ FPS
Here is some pseudocode:
void onDraw(){
super.onDraw()
curTime = getTime();
deltaTime = curTime - prevTime();
aproxFps = 1000 / deltaTime;
prevTime = curTime;
}
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