Search code examples
androidunity-game-engineframe-rate

How is gamebench implemented to calculate the FPS of unity3d games?


How does Frame per second of the unity3d game engine on android mobiles captured using gamebench

Tried using the gfxinfo over adb commands, doesnt help much ?

Need more help how to calculate the FPS of unity3d games on Android ?


Solution

  • My guess is that it uses these commands [programmatically]:

    (1) adb shell dumpsys SurfaceFlinger --latency-clear

    (2) adb shell dumpsys SurfaceFlinger --latency <window name>

    e.g.,

    adb shell dumpsys SurfaceFlinger --latency com.android.settings/com.android.settings.SubSettings
    
    RefreshPeriod <-- Time in nano seconds
    desiredPresentTime actualPresentTime frameReadyTime <-- Time in nano seconds
    desiredPresentTime actualPresentTime frameReadyTime
    desiredPresentTime actualPresentTime frameReadyTime
    ...
    

    On how to interpret the results, see https://chromium.googlesource.com/chromium/src/build/+/fefabac95d6aee4d941111e67f606dc50dfe9dd1/android/pylib/perf/surface_stats_collector.py#215 and https://android.googlesource.com/platform/frameworks/native/+/86efcc0/services/surfaceflinger/FrameTracker.cpp#217