Unity - Scripting API: RawFrameDataView
class in UnityEditor.Profiling
/
Inherits from:Profiling.FrameDataView
Success!
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Description
Provides access to the Profiler data for a specific frame and thread.
Use RawFrameDataView to retrieve unstructured Profiler samples data for the particular frame.
The order of samples is determined by the order they are generated in the code.
RawFrameDataView can quickly iterate over all samples in the frame without any internal allocations.
using System; using Unity.Collections; using UnityEditor.Profiling; using UnityEditorInternal; using UnityEngine; using UnityEngine.Profiling;public class Example { public static long GetGCAllocs(int frameIndex) { long totalGcAllocSize = 0;
int gcAllocMarkerId = FrameDataView.invalidMarkerId;
for (int threadIndex = 0;; ++threadIndex) { using (RawFrameDataView frameData = ProfilerDriver.GetRawFrameDataView(frameIndex, threadIndex)) { if (!frameData.valid) break;
if (gcAllocMarkerId == FrameDataView.invalidMarkerId) { gcAllocMarkerId = frameData.GetMarkerId("GC.Alloc"); if (gcAllocMarkerId == FrameDataView.invalidMarkerId) break; }
int sampleCount = frameData.sampleCount; for (int i = 0; i < sampleCount; ++i) { if (gcAllocMarkerId != frameData.GetSampleMarkerId(i)) continue;
long gcAllocSize = frameData.GetSampleMetadataAsLong(i, 0); totalGcAllocSize += gcAllocSize; } } }
return totalGcAllocSize; } }
Static Properties
| Property | Description |
|---|---|
| invalidSampleIndex | This constant defines a sample index that does not match any valid Profiler Sample. |
Inherited Members
Static Properties
| Property | Description |
|---|---|
| invalidMarkerId | Identifier of the invalid marker. |
| invalidThreadId | This constant defines a thread id that does not match any valid thread's id. |
| invalidThreadIndex | This constant defines a thread index that does not match any valid thread's index. |
Properties
| Property | Description |
|---|---|
| frameFps | The current frames per second (FPS) for the frame. |
| frameGpuTimeMs | The amount of GPU frame time in milliseconds. |
| frameGpuTimeNs | The amount of GPU frame time in nanoseconds. |
| frameIndex | The frame index for the FrameDataView. |
| frameStartTimeMs | The start time of CPU frame in milliseconds. |
| frameStartTimeNs | The start time of CPU frame in nanoseconds. |
| frameTimeMs | The amount of CPU frame time in milliseconds. |
| frameTimeNs | The amount of CPU frame time in nanoseconds. |
| maxDepth | Maximum child samples levels in the thread data. |
| sampleCount | The amount of samples in the frame for the thread. |
| 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. |