< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FPSColoring()0%2100%
GeFPSDisplayColor(...)0%12300%
GetPercentageColoring(...)0%12300%
GetMemoryColoring(...)0%12300%
GetDisplayColorString(...)0%2100%
GetPercentageColoringString(...)0%2100%
GetHexColor(...)0%2100%
GetColor(...)0%2100%
GetMemoryColoringString(...)0%2100%

File(s)

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

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL.FPSDisplay
 4{
 5    public class FPSColoring
 6    {
 07        private static readonly Color GREAT_COLOR = Color.green;
 08        private static readonly Color GOOD_COLOR = Color.white;
 09        private static readonly Color BAD_COLOR = Color.yellow;
 010        private static readonly Color WORSE_COLOR = new Color(0.9764706f, 0.4117647f, 0.05490196f);
 011        private static readonly Color UNBEARABLE_COLOR = Color.red;
 12
 013        public static FPSColor[] coloring =
 14        {
 15            new FPSColor(GREAT_COLOR, FPSEvaluation.GREAT),
 16            new FPSColor(GOOD_COLOR, FPSEvaluation.GOOD),
 17            new FPSColor(BAD_COLOR, FPSEvaluation.BAD),
 18            new FPSColor(WORSE_COLOR, FPSEvaluation.WORSE),
 19            new FPSColor(UNBEARABLE_COLOR, FPSEvaluation.UNBEARABLE),
 20        };
 21
 22        private static Color GeFPSDisplayColor(float fps)
 23        {
 024            for (int i = 0; i < coloring.Length; i++)
 25            {
 026                if (fps >= coloring[i].fps)
 27                {
 028                    return coloring[i].color;
 29                }
 30            }
 031            return coloring[coloring.Length - 1].color;
 32        }
 33
 34        private static Color GetPercentageColoring(float value, float limit)
 35        {
 036            float currentPercentage = value / limit;
 037            if (currentPercentage > 0.99)
 38            {
 039                return UNBEARABLE_COLOR;
 40            }
 041            if (currentPercentage > 0.9)
 42            {
 043                return BAD_COLOR;
 44            }
 045            return GOOD_COLOR;
 46        }
 47
 48        private static Color GetMemoryColoring(float memoryValue)
 49        {
 050            if (memoryValue > 1800)
 51            {
 052                return UNBEARABLE_COLOR;
 53            }
 054            if (memoryValue > 1500)
 55            {
 056                return BAD_COLOR;
 57            }
 058            return GOOD_COLOR;
 59        }
 60
 061        public static string GetDisplayColorString(float fps) { return GetColor(GetHexColor(GeFPSDisplayColor(fps))); }
 62
 063        public static string GetPercentageColoringString(int value, int limit) { return GetColor(GetHexColor(GetPercenta
 64
 065        private static string GetHexColor(Color color) { return $"#{ColorUtility.ToHtmlStringRGB(color)}"; }
 66
 067        private static string GetColor(string color) { return $"<color={color}>"; }
 68
 069        public static object GetMemoryColoringString(float memoryValue) { return GetColor(GetHexColor(GetMemoryColoring(
 70    }
 71}