Reputation: 9368
Is there a way (maybe some apps, hacks, libs) to measure frames per second (FPS) during app development for Android?
Upvotes: 31
Views: 56738
Reputation: 14678
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)
Upvotes: 19
Reputation: 2022
I have used GameBench for FPS Analysis of an android application(it is not a game, I wanted to check the FPS when an animation of my app starts running). GameBench captures key frame rate (FPS) metrics, which are the best objective indicator of the fluidity of a UX.
My requirement was to verify the FPS to be 30FPS when an animation of my android application starts.
I have verified the following with the Graph report provided by the GameBench tool,
See screenshot.
To use this tool, you have to install an android application and a desktop launcher.
Reference:
As a side note,
I have used FPS Meter app also, but it seems inaccurate in my case. Got 29FPS to 31 FPS when my animation in the android application starts. Expected FPS is 30FPS.
https://play.google.com/store/apps/details?id=com.ftpie.fpsmeter&hl=en
Upvotes: 6
Reputation: 971
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.
Upvotes: 32