using UnityEngine;

internal class FramerateProfiler
{
	private float _lastTime;

	private int _lastFrame;

	private float _fps;

	private bool _hasValue;

	private const float MEASURE_RANGE = 5f;

	public const int FPS_GOOD = 30;

	public const int FPS_BAD = 20;

	public float? Fps
	{
		get
		{
			if (_hasValue)
			{
				return _fps;
			}
			return null;
		}
	}

	public void Init()
	{
		_lastTime = Time.realtimeSinceStartup;
		_lastFrame = Time.frameCount;
		_fps = 30f;
	}

	public void Update()
	{
		float realtimeSinceStartup = Time.realtimeSinceStartup;
		float num = realtimeSinceStartup - _lastTime;
		if (num >= 5f)
		{
			int num2 = Time.frameCount - _lastFrame;
			_fps = (float)num2 / num;
			_lastTime = realtimeSinceStartup;
			_lastFrame = Time.frameCount;
			_hasValue = true;
		}
	}
}
