GetSampleMarkerId(int)
Gets Profiler marker indentifier which uniquely identifies sample name.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前
Definition
- Type: Method
- Namespace: UnityEditor.Profiling
- Assembly: UnityEditor.CoreModule
public int GetSampleMarkerId(int sampleIndex)
Parameters
Index of the Profiler sample.
Returns
Type | Description |
|---|---|
| int | Returns Profiler marker indentifier. Returns invalidMarkerId for invalid index. |
Remarks
The Profiler uses unique identifier for each marker created during profiling session. Marker can generate many samples which can be retrieved by RawFrameDataView.
All samples generated by the same marker have the same integer marker identifier and the same name.
Marker identifiers are persistent for the entire profiling session.
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: RawFrameDataView.GetSampleName, FrameDataView.GetMarkerId, FrameDataView.GetMarkerName.