Last active
December 22, 2019 07:40
-
-
Save n-taku/460ca8e9ef3ef36e0b6cc2a2a44a0e3d to your computer and use it in GitHub Desktop.
MemoryのProfilerデータ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class MemoryFrameData | |
{ | |
public int totalAllocated; | |
public int textureMemory; | |
public int meshMemory; | |
public int materialCount; | |
public int objectCount; | |
public int totalGCAllocated; | |
public int globalIllumination; | |
public int gcAllocated; | |
} | |
public static MemoryFrameData ProcessMemoryFrameData(int frame) | |
{ | |
var m = new MemoryFrameData(); | |
var statistics = ProfilerDriver.GetGraphStatisticsPropertiesForArea(ProfilerArea.Memory); | |
foreach (var propertyName in statistics) | |
{ | |
var id = ProfilerDriver.GetStatisticsIdentifierForArea(ProfilerArea.Memory, propertyName); | |
var buffer = new float[1]; | |
ProfilerDriver.GetStatisticsValues(id, frame, 1, buffer, out var maxValue); | |
if (propertyName == "Total Allocated") m.totalAllocated = (int)buffer[0]; | |
else if (propertyName == "Texture Memory") m.textureMemory = (int)buffer[0]; | |
else if (propertyName == "Mesh Memory") m.meshMemory = (int)buffer[0]; | |
else if (propertyName == "Material Count") m.materialCount = (int)buffer[0]; | |
else if (propertyName == "Object Count") m.objectCount = (int)buffer[0]; | |
else if (propertyName == "Total GC Allocated") m.totalGCAllocated = (int)buffer[0]; | |
else if (propertyName == "Global Illumination") m.globalIllumination = (int)buffer[0]; | |
else if (propertyName == "GC Allocated") m.gcAllocated = (int)buffer[0]; | |
} | |
return m; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment