Is there a way (maybe some apps, hacks, libs) to measure frames per second (FPS) during app development for Android?
Go to the Settings menu. Scroll down to Developer options. Scroll down almost to the bottom until you find the monitoring section. Enable show FPS value.
You can use TinyDancer library.
Simply add code like:
public class DebugApplication extends Application { @Override public void onCreate() { // default config TinyDancer.create().show(this); //or customazed config TinyDancer.create() .redFlagPercentage(.1f) // set red indicator for 10% .startingGravity(Gravity.TOP) .startingXPosition(200) .startingYPosition(600) .show(this); } }
And you'll see interactive view with information about current FPS on top of your screens.
Note that performance will be terrible with the debugger attached.
From my own Android game, frame time can be measured with android.os.SystemClock
. That is, you call SystemClock.elapsedRealtime()
once per frame and subtract the value from the previous frame. Since elapsedRealtime()
is measured in milliseconds, calculating framerate is as simple as 1000.0 / frametime
.
You can post your code into an ongoing frame by using Choreographer#postFrameCallback
if targeting API level 16 or newer (Jelly Bean).
Also note that frametime is generally a better gauge of performance than framerate. The difference between 1000fps and 1200fps is the same amount of time as the difference between 60fps and 61fps (approximately, probably less than that though)
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