< Summary

Class:GDX.Developer.Reports.Resource.Sections.MemoryDiffSection
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/Reports/Resource/Sections/MemoryDiffSection.cs
Covered lines:22
Uncovered lines:0
Coverable lines:22
Total lines:61
Line coverage:100% (22 of 22)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:3
Method coverage:100% (3 of 3)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
MemoryDiffSection(...)0%110100%
Get(...)0%110100%
Output(...)0%220100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Developer/Reports/Resource/Sections/MemoryDiffSection.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5#if !UNITY_DOTSRUNTIME
 6
 7using System.Text;
 8
 9namespace GDX.Developer.Reports.Resource.Sections
 10{
 11    /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception>
 12    public readonly struct MemoryDiffSection
 13    {
 14        public readonly LongDiff MonoHeapSize;
 15        public readonly LongDiff MonoUsedSize;
 16        public readonly LongDiff UnityGraphicsDriverAllocated;
 17        public readonly LongDiff UnityTotalAllocatedMemory;
 18        public readonly LongDiff UnityTotalReservedMemory;
 19        public readonly LongDiff UnityTotalUnusedReservedMemory;
 20
 21        public MemoryDiffSection(MemorySection lhs, MemorySection rhs)
 122        {
 123            MonoUsedSize = new LongDiff(lhs.MonoUsedSize, rhs.MonoUsedSize);
 124            MonoHeapSize = new LongDiff(lhs.MonoHeapSize, rhs.MonoHeapSize);
 125            UnityTotalAllocatedMemory =
 26                new LongDiff(lhs.UnityTotalAllocatedMemory, rhs.UnityTotalAllocatedMemory);
 127            UnityTotalReservedMemory =
 28                new LongDiff(lhs.UnityTotalReservedMemory, rhs.UnityTotalReservedMemory);
 129            UnityTotalUnusedReservedMemory = new LongDiff(lhs.UnityTotalUnusedReservedMemory,
 30                rhs.UnityTotalUnusedReservedMemory);
 131            UnityGraphicsDriverAllocated = new LongDiff(lhs.UnityGraphicsDriverAllocatedMemory,
 32                rhs.UnityGraphicsDriverAllocatedMemory);
 133        }
 34
 35        public static MemoryDiffSection Get(MemorySection lhs, MemorySection rhs)
 136        {
 137            return new MemoryDiffSection(lhs, rhs);
 138        }
 39
 40        public void Output(ResourceReportContext context, StringBuilder builder, bool detailed = true)
 141        {
 142            builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Mono Heap",
 43                MonoHeapSize.GetSizeOutput(context)));
 144            builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Used Mono Heap",
 45                MonoUsedSize.GetSizeOutput(context)));
 46
 147            if (detailed)
 148            {
 149                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "GFX Driver Allocated Memory",
 50                    UnityGraphicsDriverAllocated.GetSizeOutput(context)));
 151                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Reserved Memory",
 52                    UnityTotalReservedMemory.GetSizeOutput(context)));
 153                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Allocated Memory",
 54                    UnityTotalAllocatedMemory.GetSizeOutput(context)));
 155                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Unused Reserved Memory",
 56                    UnityTotalUnusedReservedMemory.GetSizeOutput(context)));
 157            }
 158        }
 59    }
 60}
 61#endif // !UNITY_DOTSRUNTIME