Skip to content

Instantly share code, notes, and snippets.

@n-taku
Last active December 22, 2019 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n-taku/460ca8e9ef3ef36e0b6cc2a2a44a0e3d to your computer and use it in GitHub Desktop.
Save n-taku/460ca8e9ef3ef36e0b6cc2a2a44a0e3d to your computer and use it in GitHub Desktop.
MemoryのProfilerデータ
[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