< Summary

Class:DCL.FPSDisplay.FPSDisplay
Assembly:FPSDisplay
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/Debugging/FPSDisplay/FPSDisplay.cs
Covered lines:22
Uncovered lines:1
Coverable lines:23
Total lines:62
Line coverage:95.6% (22 of 23)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
OnEnable()0%3.143075%
OnDisable()0%110100%
UpdateLabelLoop()0%330100%
UpdateLabel()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/Debugging/FPSDisplay/FPSDisplay.cs

#LineLine coverage
 1using System.Collections;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5namespace DCL.FPSDisplay
 6{
 7
 8    public class FPSDisplay : MonoBehaviour
 9    {
 10        private const float REFRESH_SECONDS = 0.1f;
 11
 12        [SerializeField] private Text label;
 13        [SerializeField] private PerformanceMetricsDataVariable performanceData;
 14
 15        private void OnEnable()
 16        {
 1017            if (label == null || performanceData == null)
 018                return;
 19
 1020            StartCoroutine(UpdateLabelLoop());
 1021        }
 22
 2023        private void OnDisable() { StopAllCoroutines(); }
 24
 25        private IEnumerator UpdateLabelLoop()
 26        {
 127            while (true)
 28            {
 1129                UpdateLabel();
 30
 1131                yield return new WaitForSeconds(REFRESH_SECONDS);
 32            }
 33        }
 34
 35        private void UpdateLabel()
 36        {
 1137            float dt = Time.unscaledDeltaTime;
 38
 1139            float fps = performanceData.Get().fpsCount;
 40
 1141            string fpsFormatted = fps.ToString("##");
 1142            string msFormatted = (dt * 1000).ToString("##");
 43
 1144            string targetText = string.Empty;
 45
 46
 1147            string NO_DECIMALS = "##";
 1148            string TWO_DECIMALS = "##.00";
 1149            targetText += $"Hiccups in the last 1000 frames: {performanceData.Get().hiccupCount}\n";
 1150            targetText += $"Hiccup loss: {(100.0f * performanceData.Get().hiccupSum / performanceData.Get().totalSeconds
 1151            targetText += $"Bad Frames Percentile: {((performanceData.Get().hiccupCount) / 10.0f).ToString(NO_DECIMALS)}
 1152            targetText += $"Current {msFormatted} ms (fps: {fpsFormatted})";
 53
 1154            if (label.text != targetText)
 55            {
 1156                label.text = targetText;
 57            }
 58
 1159            FPSColoring.DisplayColor(label, fps);
 1160        }
 61    }
 62}