|  |  | 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 |  |  | 
|  |  | 7 |  | using System.Text; | 
|  |  | 8 |  |  | 
|  |  | 9 |  | namespace 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) | 
|  | 1 | 22 |  |         { | 
|  | 1 | 23 |  |             MonoUsedSize = new LongDiff(lhs.MonoUsedSize, rhs.MonoUsedSize); | 
|  | 1 | 24 |  |             MonoHeapSize = new LongDiff(lhs.MonoHeapSize, rhs.MonoHeapSize); | 
|  | 1 | 25 |  |             UnityTotalAllocatedMemory = | 
|  |  | 26 |  |                 new LongDiff(lhs.UnityTotalAllocatedMemory, rhs.UnityTotalAllocatedMemory); | 
|  | 1 | 27 |  |             UnityTotalReservedMemory = | 
|  |  | 28 |  |                 new LongDiff(lhs.UnityTotalReservedMemory, rhs.UnityTotalReservedMemory); | 
|  | 1 | 29 |  |             UnityTotalUnusedReservedMemory = new LongDiff(lhs.UnityTotalUnusedReservedMemory, | 
|  |  | 30 |  |                 rhs.UnityTotalUnusedReservedMemory); | 
|  | 1 | 31 |  |             UnityGraphicsDriverAllocated = new LongDiff(lhs.UnityGraphicsDriverAllocatedMemory, | 
|  |  | 32 |  |                 rhs.UnityGraphicsDriverAllocatedMemory); | 
|  | 1 | 33 |  |         } | 
|  |  | 34 |  |  | 
|  |  | 35 |  |         public static MemoryDiffSection Get(MemorySection lhs, MemorySection rhs) | 
|  | 1 | 36 |  |         { | 
|  | 1 | 37 |  |             return new MemoryDiffSection(lhs, rhs); | 
|  | 1 | 38 |  |         } | 
|  |  | 39 |  |  | 
|  |  | 40 |  |         public void Output(ResourceReportContext context, StringBuilder builder, bool detailed = true) | 
|  | 1 | 41 |  |         { | 
|  | 1 | 42 |  |             builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Mono Heap", | 
|  |  | 43 |  |                 MonoHeapSize.GetSizeOutput(context))); | 
|  | 1 | 44 |  |             builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Used Mono Heap", | 
|  |  | 45 |  |                 MonoUsedSize.GetSizeOutput(context))); | 
|  |  | 46 |  |  | 
|  | 1 | 47 |  |             if (detailed) | 
|  | 1 | 48 |  |             { | 
|  | 1 | 49 |  |                 builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "GFX Driver Allocated Memory", | 
|  |  | 50 |  |                     UnityGraphicsDriverAllocated.GetSizeOutput(context))); | 
|  | 1 | 51 |  |                 builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Reserved Memory", | 
|  |  | 52 |  |                     UnityTotalReservedMemory.GetSizeOutput(context))); | 
|  | 1 | 53 |  |                 builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Allocated Memory", | 
|  |  | 54 |  |                     UnityTotalAllocatedMemory.GetSizeOutput(context))); | 
|  | 1 | 55 |  |                 builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Total Unused Reserved Memory", | 
|  |  | 56 |  |                     UnityTotalUnusedReservedMemory.GetSizeOutput(context))); | 
|  | 1 | 57 |  |             } | 
|  | 1 | 58 |  |         } | 
|  |  | 59 |  |     } | 
|  |  | 60 |  | } | 
|  |  | 61 |  | #endif // !UNITY_DOTSRUNTIME |