RawFrameDataView
Provides access to the Profiler data for a specific frame and thread.
Read time 4 minutesLast updated 11 days ago
Definition
- Type: Class
- Namespace: UnityEditor.Profiling
- Assembly: UnityEditor
- Inherits from: FrameDataView
- Implements: IDisposable
public class RawFrameDataView : FrameDataView, IDisposable
Remarks
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; }}
Additional Resources: FrameDataView, HierarchyFrameDataView.
Static Fields
Value | Description |
|---|---|
| invalidSampleIndex | This constant defines a sample index that does not match any valid Profiler Sample. |
Methods
Method | Description |
|---|---|
| GetFlowEvents | Gets all flow events for the current frame and thread. |
| GetSampleCallstack | Gets the callstack associated with the specified sample. |
| GetSampleCategoryIndex | Gets Profiler marker category for the specific sample. |
| GetSampleChildrenCount | Gets amount of child samples for the specific sample. |
| GetSampleChildrenCountRecursive | Gets amount of direct and indirect child samples for the specific sample. |
| GetSampleFlags | Gets Profiler marker flags for the specific sample. |
| GetSampleFlowEvents | Gets the flow events that originate from the specific sample. |
| GetSampleMarkerId | Gets Profiler marker indentifier which uniquely identifies sample name. |
| GetSampleMetadataAsDouble | Gets sample metadata value as double. |
| GetSampleMetadataAsFloat | Gets sample metadata value as float. |
| GetSampleMetadataAsInt | Gets sample metadata value as integer. |
| GetSampleMetadataAsLong | Gets sample metadata value as long. |
| GetSampleMetadataAsSpan | Returns Span\<T\> representation of sample metadata. |
| GetSampleMetadataAsString | Gets sample metadata value as string. |
| GetSampleMetadataCount | Gets metadata count associated with the specific sample. |
| GetSampleName | Gets the name of the specific sample. |
| GetSampleStartTimeMs | Gets the start time of the sample. The amount of time is expressed in milliseconds. |
| GetSampleStartTimeNs | Gets the start time of the sample. The amount of time is expressed in nanoseconds. |
| GetSampleTimeMs | Gets the duration of sample. The amount of time is expressed in milliseconds. |
| GetSampleTimeNs | Gets the duration of sample. The amount of time is expressed in nanoseconds. |
Structs
Struct | Description |
|---|---|
| RawFrameDataView.FlowEvent | This struct describes profiler flow and its relation to the specific sample in the frame. |