Skip to content

Instantly share code, notes, and snippets.

@n-taku
Last active December 22, 2019 07:47
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/807442fa8b45c027b3deb8a683e36d90 to your computer and use it in GitHub Desktop.
Save n-taku/807442fa8b45c027b3deb8a683e36d90 to your computer and use it in GitHub Desktop.
CPUのHierarchyのProfilerデータを取得
[Serializable]
public class HierarchyFrameData
{
public float frameFps;
public float frameTimeMs;
public float frameGpuTimeMs;
public float frameIndex;
public List<HierarchyItemFrameData> hierarchyFrameData = new List<HierarchyItemFrameData>();
}
[Serializable]
public class HierarchyItemFrameData
{
public string itemName;
public string itemPath;
public string columnName;
public string columnObjectName;
public int columnCalls;
public float columnGcMemory;
public float columnSelfTime;
public string columnSelfPercent;
public float columnTotalTime;
public string columnTotalPercent;
}
public static HierarchyFrameData ProcessHierarchyFrameData(int frame)
{
var f = new HierarchyFrameData();
using (var frameData = ProfilerDriver.GetHierarchyFrameDataView(frame, 0, HierarchyFrameDataView.ViewModes.MergeSamplesWithTheSameName, HierarchyFrameDataView.columnGcMemory, false))
{
f.frameFps = frameData.frameFps;
f.frameTimeMs = frameData.frameTimeMs;
f.frameGpuTimeMs = frameData.frameGpuTimeMs;
f.frameIndex = frameData.frameIndex;
int rootId = frameData.GetRootItemID();
frameData.GetItemDescendantsThatHaveChildren(rootId, parentsCacheList);
foreach (int parentId in parentsCacheList)
{
frameData.GetItemChildren(parentId, childrenCacheList);
foreach (var child in childrenCacheList)
{
var h = new HierarchyItemFrameData();
h.itemName = frameData.GetItemName(child);
h.itemPath = frameData.GetItemPath(child);
h.columnName = frameData.GetItemColumnData(child, HierarchyFrameDataView.columnName);
h.columnObjectName = frameData.GetItemColumnData(child, HierarchyFrameDataView.columnObjectName);
h.columnCalls = (int)frameData.GetItemColumnDataAsSingle(child, HierarchyFrameDataView.columnCalls);
h.columnGcMemory = frameData.GetItemColumnDataAsSingle(child, HierarchyFrameDataView.columnGcMemory);
h.columnSelfTime = frameData.GetItemColumnDataAsSingle(child, HierarchyFrameDataView.columnSelfTime);
h.columnSelfPercent = frameData.GetItemColumnData(child, HierarchyFrameDataView.columnSelfPercent);
h.columnTotalTime = frameData.GetItemColumnDataAsSingle(child, HierarchyFrameDataView.columnTotalTime);
h.columnTotalPercent = frameData.GetItemColumnData(child, HierarchyFrameDataView.columnTotalPercent);
f.hierarchyFrameData.Add(h);
}
}
}
return f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment