using System.Globalization;
using TMPro;
using UnityEngine;

namespace Cryville.EEW.Unity.UI {
	[RequireComponent(typeof(TMP_Text))]
	class StatusView : MonoBehaviour {
		TMP_Text _textView;

		void Awake() {
			_textView = GetComponent<TMP_Text>();
		}

		void Update() {
			_textView.text = string.Format(
				CultureInfo.InvariantCulture,
				"FPS: i{0:0} / s{1:0}\nSMem: {2:N0} / {3:N0}\nIMem: {4:N0} / {5:N0}",
				1 / Time.deltaTime,
				1 / Time.smoothDeltaTime,
				UnityEngine.Profiling.Profiler.GetMonoUsedSizeLong(),
				UnityEngine.Profiling.Profiler.GetMonoHeapSizeLong(),
				UnityEngine.Profiling.Profiler.GetTotalAllocatedMemoryLong(),
				UnityEngine.Profiling.Profiler.GetTotalReservedMemoryLong()
			);
		}
	}
}
