< Summary

Class:GDX.Developer.Reports.Resource.Sections.MemorySection
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/Reports/Resource/Sections/MemorySection.cs
Covered lines:22
Uncovered lines:0
Coverable lines:22
Total lines:87
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)

./Packages/com.dotbunny.gdx/GDX/Developer/Reports/Resource/Sections/MemorySection.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;
 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
 58        public static MemorySection Get()
 659        {
 660            return new MemorySection(Profiler.GetMonoHeapSizeLong(), Profiler.GetMonoUsedSizeLong(),
 61                Profiler.GetTotalAllocatedMemoryLong(), Profiler.GetTotalReservedMemoryLong(),
 62                Profiler.GetTotalUnusedReservedMemoryLong(), Profiler.GetAllocatedMemoryForGraphicsDriver());
 663        }
 64
 65        public void Output(ResourceReportContext context, StringBuilder builder,
 66            bool detailed = true)
 467        {
 468            builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Mono Heap",
 69                Localization.GetHumanReadableFileSize(MonoHeapSize)));
 470            builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Used Mono Heap",
 71                Localization.GetHumanReadableFileSize(MonoUsedSize)));
 72
 473            if (detailed)
 474            {
 475                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "GFX Driver Allocated Memory",
 76                    Localization.GetHumanReadableFileSize(UnityGraphicsDriverAllocatedMemory)));
 477                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Reserved Memory",
 78                    Localization.GetHumanReadableFileSize(UnityTotalReservedMemory)));
 479                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Allocated Memory",
 80                    Localization.GetHumanReadableFileSize(UnityTotalAllocatedMemory)));
 481                builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Unused Reserved Memory",
 82                    Localization.GetHumanReadableFileSize(UnityTotalUnusedReservedMemory)));
 483            }
 484        }
 85    }
 86}
 87#endif // !UNITY_DOTSRUNTIME

Coverage by test methods






Methods/Properties

MemorySection(System.Int64, System.Int64, System.Int64, System.Int64, System.Int64, System.Int64)
Get()
Output(GDX.Developer.Reports.Resource.ResourceReportContext, System.Text.StringBuilder, System.Boolean)