How to calculate device level FPS in android

Does anyone have an idea on how to get the FPS (frame per second) of an Android device?

There is an option in the development settings to display FPS, but I want to write an application to do the same.

It internally calls the surfaceflinger api.

+4
source share
2 answers

In your main Activity class, override the onDraw() method. Call super.onDraw() , then save the current system time. Compute delta_time in ms between the current draw call and the previous draw call. Then calculate FPS with 1000 ms / delta_time ~ FPS

Here are a few pseudo codes:

 void onDraw(){ super.onDraw() curTime = getTime(); deltaTime = curTime - prevTime(); aproxFps = 1000 / deltaTime; prevTime = curTime; } 
+4
source

This is not something you can do if you do not start the device and do not fall under the hood.

0
source

Source: https://habr.com/ru/post/1411164/


All Articles