using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestScript : MonoBehaviour { // current frame rate = 1 / Time.deltaTime; units are: frames/second float _maxFrameRate = 0; // maximum frame rate float _minFrameRate = float.MaxValue; // minimum frame rate (the large initialization value is overwritten on the first frame) public int FrameInterval = 50; // number of frames to wait before printing out and then resetting stats // Update is called once per frame void Update() { float currentFrameRate = 1 / Time.deltaTime; _maxFrameRate = Mathf.Max(_maxFrameRate, currentFrameRate); _minFrameRate = Mathf.Min(_minFrameRate, currentFrameRate); if(Time.frameCount % FrameInterval == 0) // % is the remainder operator { Debug.Log("After " + Time.frameCount + " frames:"); Debug.Log("max frame frate for last " + FrameInterval + " frames: " + _maxFrameRate + " frames/sec"); Debug.Log("min frame frate for last " + FrameInterval + " frames: " + _minFrameRate + " frames/sec"); _maxFrameRate = 0; _minFrameRate = float.MaxValue; } } }