< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
OnEnable()0%12300%
OnDisable()0%2100%
UpdateLabelLoop()0%12300%
UpdateLabel()0%6200%

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        {
 017            if (label == null || performanceData == null)
 018                return;
 19
 020            StartCoroutine(UpdateLabelLoop());
 021        }
 22
 023        private void OnDisable() { StopAllCoroutines(); }
 24
 25        private IEnumerator UpdateLabelLoop()
 26        {
 027            while (true)
 28            {
 029                UpdateLabel();
 30
 031                yield return new WaitForSeconds(REFRESH_SECONDS);
 32            }
 33        }
 34
 35        private void UpdateLabel()
 36        {
 037            float dt = Time.unscaledDeltaTime;
 38
 039            float fps = performanceData.Get().fpsCount;
 40
 041            string fpsFormatted = fps.ToString("##");
 042            string msFormatted = (dt * 1000).ToString("##");
 43
 044            string targetText = string.Empty;
 45
 46
 047            string NO_DECIMALS = "##";
 048            string TWO_DECIMALS = "##.00";
 049            targetText += $"Hiccups in the last 1000 frames: {performanceData.Get().hiccupCount}\n";
 050            targetText += $"Hiccup loss: {(100.0f * performanceData.Get().hiccupSum / performanceData.Get().totalSeconds
 051            targetText += $"Bad Frames Percentile: {((performanceData.Get().hiccupCount) / 10.0f).ToString(NO_DECIMALS)}
 052            targetText += $"Current {msFormatted} ms (fps: {fpsFormatted})";
 53
 054            if (label.text != targetText)
 55            {
 056                label.text = targetText;
 57            }
 58
 059            FPSColoring.DisplayColor(label, fps);
 060        }
 61    }
 62}