AJ222
AJ222

Reputation: 1134

Get FPS of an android game using ADB

We want to get the FPS on an android game using ADB. The methods we found online like this return the fps of of the activity itself(keep returning 60 fps even while the game reaches 10 fps) and not the real game fps.

Anyone knows how to get the real game fps via adb?

If not possible, we are also open to use any kind of command line tool to get that info

Upvotes: 1

Views: 13014

Answers (1)

Maurice Lam
Maurice Lam

Reputation: 1794

Edit: Looks like you are trying to get the data for a SurfaceView, so you will need to use the info from dumpsys SurfaceFlinger instead.

You can get the surface name from

adb shell dumpsys SurfaceFlinger --list

And then get the latency data using --latency. For example, for Angry Birds 2, I can use the following command to get when the frames are drawn.

adb shell dumpsys SurfaceFlinger --latency SurfaceView[com.rovio.baba/com.unity3d.player.UnityPlayerActivity]#0

The comments from this class explains the output format:

 adb shell dumpsys SurfaceFlinger --latency <window name>
 prints some information about the last 128 frames displayed in
 that window.
 The data returned looks like this:
 16954612
 7657467895508   7657482691352   7657493499756
 7657484466553   7657499645964   7657511077881
 7657500793457   7657516600576   7657527404785
 (...)

 The first line is the refresh period (here 16.95 ms), it is followed
 by 128 lines w/ 3 timestamps in nanosecond each:
 A) when the app started to draw
 B) the vsync immediately preceding SF submitting the frame to the h/w
 C) timestamp immediately after SF submitted that frame to the h/w

 The difference between the 1st and 3rd timestamp is the frame-latency.
 An interesting data is when the frame latency crosses a refresh period
 boundary, this can be calculated this way:

 ceil((C - A) / refresh-period)

 (each time the number above changes, we have a "jank").
 If this happens a lot during an animation, the animation appears
 janky, even if it runs at 60 fps in average.

Edit: Below is the old answer for getting the framerate for regular view hierarchies, but doesn't work for SurfaceViews.

You can get that information from adb shell dumpsys gfxinfo.

From https://developer.android.com/training/testing/performance. In particular:

With Android 6.0 comes a new command for gfxinfo, and that’s framestats which provides extremely detailed frame timing information from recent frames, so that you can track down and debug problems more accurately.

Each line of this output represents a frame produced by the app. Each line has a fixed number of columns describing time spent in each stage of the frame-producing pipeline. The next section describes this format in detail, including what each column represents.

You can calculate the fps from those timestamps.

Upvotes: 2

Related Questions