Unity 2017 frame rate capped?

I’m trying to determine the frame rate of my game - I open a new project with nothing but the default 3d scene (Main Camera + Direction Light) and hit play - the frame rate in stats window bounces between 68 and 70 fps.

This script (which I want to use in order to see the fps on the actual Android device) says the frame rate is consistently @ 59 fps

using UnityEngine;
using System.Collections;

public class TestFPS : MonoBehaviour
{

    private int FramesPerSec;
    private float frequency = 1.0f;
    private string fps;

    void Start()
    {
        StartCoroutine(FPS());
    }

    private IEnumerator FPS()
    {
        for (;;)
        {
            // Capture frame-per-second
            int lastFrameCount = Time.frameCount;
            float lastTime = Time.realtimeSinceStartup;
            yield return new WaitForSeconds(frequency);
            float timeSpan = Time.realtimeSinceStartup - lastTime;
            int frameCount = Time.frameCount - lastFrameCount;

            // Display it

            fps = string.Format("FPS: {0}", (frameCount / timeSpan));
        }
    }

    void OnGUI()
    {
        GUI.Label(new Rect(Screen.width - 100, 10, 150, 20), fps);
    }
}

a) I’m wondering why the fps is so low with nothing in the scene?

b) why are the frame rates off by so much?

c) anyone suggest another method for testing fps on android devices?

Thanks for any help

You might want to turn of V-Sync in unity, is locate in Edit → Project Setting → Quality, change V Sync Count to “Don’t Sync”.

@digzelot


a) The FPS is in the editor can be low because of many reasons -

  • Computer specifications aren’t great. Having more RAM, better CPU and a larger GPU will greatly improve that.
  • That FPS is with the editor running which itself consumes a lot of computing resources and hence lowers the FPS. (You can take a Windows/Mac build of your project to see the improvement in FPS when the editor is not running.)
  • Graphical and Quality settings. (However their impact will be minimal on an almost empty project). Try tweaking those.

b) If you are talking about the difference in FPS in the editor and that of the Android build, that is because displays on most mobile devices have refresh rates capped at 60Hz (Limitation of mobile displays). So you cannot have an FPS of over 60 on any mobile device (except the Razor phone which is capped at 120Hz). 59 is probably the best you can get. (Your script won’t even display 60 cause of minor minor fluctuations while refreshing. To see how close to 60 you can get, just try printing 1/Time.deltaTime every frame.)


c) Your script is a good implementation of displaying FPS. If you wish, you can try downloading FPS assets from the store.