< Summary

Class:GDX.Developer.Reports.Resource.Sections.MemorySection
Assembly:GDX
File(s):D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/Developer/Reports/Resource/Sections/MemorySection.cs
Covered lines:22
Uncovered lines:0
Coverable lines:22
Total lines:86
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
MemorySection(...)0%110100%
Get()0%110100%
Output(...)0%220100%

File(s)

D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/Developer/Reports/Resource/Sections/MemorySection.cs

#LineLine coverage
 1// Copyright (c) 2020-2022 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;
 8using UnityEngine.Profiling;
 9
 10namespace GDX.Developer.Reports.Resource.Sections
 11{
 12    /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception>
 13    public readonly struct MemorySection
 14    {
 15        /// <summary>
 16        ///     The size of the Mono heap when the <see cref="ResourcesAuditReport" /> was created.
 17        /// </summary>
 18        /// <remarks>This is cached so that the <see cref="ResourcesAuditReport" /> does not effect this value.</remarks
 19        public readonly long MonoHeapSize;
 20
 21        /// <summary>
 22        ///     The amount of the Mono heap used when the <see cref="ResourcesAuditReport" /> was created.
 23        /// </summary>
 24        /// <remarks>This is cached so that the <see cref="ResourcesAuditReport" /> does not effect this value.</remarks
 25        public readonly long MonoUsedSize;
 26
 27        /// <summary>
 28        ///     Unity's allocated native memory for the graphics driver (in bytes).
 29        /// </summary>
 30        public readonly long UnityGraphicsDriverAllocatedMemory;
 31
 32        /// <summary>
 33        ///     Unity's total allocated memory (in bytes).
 34        /// </summary>
 35        public readonly long UnityTotalAllocatedMemory;
 36
 37        /// <summary>
 38        ///     Unity's total reserved memory (in bytes).
 39        /// </summary>
 40        public readonly long UnityTotalReservedMemory;
 41
 42        /// <summary>
 43        ///     Unity's total unused reserved memory (in bytes).
 44        /// </summary>
 45        public readonly long UnityTotalUnusedReservedMemory;
 46
 47        public MemorySection(long monoHeapSize, long monoUsedSize, long unityTotalAllocatedMemory,
 48            long unityTotalReservedMemory, long unityTotalUnusedReservedMemory, long unityGraphicsDriverAllocatedMemory)
 649        {
 650            MonoHeapSize = monoHeapSize;
 651            MonoUsedSize = monoUsedSize;
 652            UnityTotalAllocatedMemory = unityTotalAllocatedMemory;
 653            UnityTotalReservedMemory = unityTotalReservedMemory;
 654            UnityTotalUnusedReservedMemory = unityTotalUnusedReservedMemory;
 655            UnityGraphicsDriverAllocatedMemory = unityGraphicsDriverAllocatedMemory;
 656        }
 57        public static MemorySection Get()
 658        {
 659            return new MemorySection(Profiler.GetMonoHeapSizeLong(), Profiler.GetMonoUsedSizeLong(),
 60                Profiler.GetTotalAllocatedMemoryLong(), Profiler.GetTotalReservedMemoryLong(),
 61                Profiler.GetTotalUnusedReservedMemoryLong(), Profiler.GetAllocatedMemoryForGraphicsDriver());
 662        }
 63
 64        public void Output(ResourceReportContext context, StringBuilder builder,
 65            bool detailed = true)
 466        {
 467            builder.AppendLine(ResourceReport.CreateKeyValuePair(context,"Total Mono Heap",
 68                Localization.GetHumanReadableFileSize(MonoHeapSize)));
 469            builder.AppendLine(ResourceReport.CreateKeyValuePair(context,"Used Mono Heap",
 70                Localization.GetHumanReadableFileSize(MonoUsedSize)));
 71
 472            if (detailed)
 473            {
 474                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "GFX Driver Allocated Memory",
 75                    Localization.GetHumanReadableFileSize(UnityGraphicsDriverAllocatedMemory)));
 476                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Reserved Memory",
 77                    Localization.GetHumanReadableFileSize(UnityTotalReservedMemory)));
 478                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Allocated Memory",
 79                    Localization.GetHumanReadableFileSize(UnityTotalAllocatedMemory)));
 480                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Unused Reserved Memory",
 81                    Localization.GetHumanReadableFileSize(UnityTotalUnusedReservedMemory)));
 482            }
 483        }
 84    }
 85}
 86#endif