INNER CODE UNIT · C#

FPSCounter

endlesstravel/Love2dCS · csharp_src/Love.FPSCounter.cs:8

    public class FPSCounter
    {
        static List<double> frameInOneSeconed = new List<double>();

        internal static void Step()
        {
            double now = Timer.GetSystemTime();
            frameInOneSeconed = frameInOneSeconed.Where(item => item > (now - 1f)).ToList();
            frameInOneSeconed.Add(now);
        }

        /// <summary>
        /// Get the amount of frame from last one seconds.
        /// </summary>
        /// <returns></returns>
        public static int GetFPS()
        {
            return frameInOneSeconed.Count;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…