Provides access to the Profiler data for a specific frame and thread.
Use HierarchyFrameDataView to retrieve Profiler samples structured as a hierarchy.
This is used in the Hierachy mode of the CPU Usage Profiler, for example.
The HierarchyFrameDataView aggregates the data with time and memory information. Each hierarchy item includes accumulated data of its children.
using System; using System.Collections.Generic; using UnityEditor.Profiling; using UnityEditorInternal;
public class Example { List<int> parentsCacheList = new List<int>(); List<int> childrenCacheList = new List<int>();
public void ProcessFrameData(int frame) { using (var frameData = ProfilerDriver.GetHierarchyFrameDataView(frame, 0, HierarchyFrameDataView.ViewModes.Default, HierarchyFrameDataView.columnGcMemory, false)) { int rootId = frameData.GetRootItemID(); frameData.GetItemDescendantsThatHaveChildren(rootId, parentsCacheList); foreach (int parentId in parentsCacheList) { frameData.GetItemChildren(parentId, childrenCacheList); // Process further records } } } }
columnCalls | The Calls column. |
columnDontSort | The column identifier that indicates whether sorting is disabled. |
columnGcMemory | The GC Allocation column. |
columnName | The Profiler Sample Name column. |
columnObjectName | The Object Name column. |
columnSelfPercent | The percentage of the time CPU spends in a call itself. |
columnSelfTime | The amount of the time CPU spends in a call itself. The amount of time is expressed in milliseconds. |
columnTotalPercent | The percentage of time the CPU spends in a call hierarchy. |
columnTotalTime | The amount of time the CPU spends in a call hierarchy. The amount of time is expressed in milliseconds. |
columnWarningCount | The amount of samples that are inside a code execution path that is suboptimal for performance. |
invalidSampleId | Index of the invalid item. |
frameFps | The current frames per second (fps) for the frame. |
frameGpuTimeMs | The amount of GPU frame time in milliseconds. |
frameIndex | The frame index for the HierarchyFrameDataView. |
frameTimeMs | The amount of CPU frame time in milliseconds. |
sortColumn | The column identifier that defines the sort column. |
sortColumnAscending | Whether the sorting order is ascending, true, or descending, false. |
threadGroupName | The name of the group that the thread belongs to. |
threadId | Persistent identifier associated with the thread. |
threadIndex | The index of the thread in the current frame. |
threadName | Name of the thread. |
valid | True after the frame data for the thread is processed and ready for retrieval. |
viewMode | The view mode which defines how data is aggregated. |
GetFrameMetaData | Retrieves metadata associated with the frame. |
GetFrameMetaDataCount | Gets the total number of metadata chunks for each id and tag pair in the frame. |
GetItemAncestors | Retrieves a list of hierarchy item ancestors. |
GetItemChildren | Retrieves a list of hierarchy item children. |
GetItemColumnData | Returns string representation of hierarchy item value associated with the column. |
GetItemColumnDataAsSingle | Returns float representation of hierarchy item value associated with the column. |
GetItemDepth | Returns hierarchy level of the item. |
GetItemDescendantsThatHaveChildren | Use to retrieve a list of a hierarchy item descendants which have other children. |
GetItemInstanceID | Returns InstanceID of the UnityEngine.Object associated with the sample. |
GetItemMarkerID | Returns Profiler marker which uniquely identifies sample name. |
GetItemMarkerIDPath | Use to retrieve a list of a marker identifiers of all hierarchy item parents. |
GetItemMergedSamplesColumnData | Use to retrieve a values of merged samples of a hierarchy item. |
GetItemMergedSamplesColumnDataAsFloats | Retrieves the merged samples for a specific hierarchy item. Merged samples are returned as a list of floats through the outValues param. |
GetItemMergedSamplesCount | Return merged samples count represented by the hierarchy item. |
GetItemMergedSamplesInstanceID | Retrieves the instanceID of the merged samples corresponding to a hierarchy item. |
GetItemName | Gets the sample name associated with the item. |
GetItemPath | Retrieves the hierarchy item path as a string. Each level is delimited by forward slashes ('/'). |
GetRootItemID | Gets the identifier for the root tree item. |
HasItemChildren | Checks whether the tree item has children. |
ResolveItemCallstack | Gets the callstack associated with the specified hierarchy item. |
ResolveItemMergedSampleCallstack | Gets the callstack associated with a specific item sample. |
Sort | Sorts the hierarchy view. |