ドキュメント

Unity Engine

Unity Engine

ProfilerMarker.AutoScope

Helper IDisposable struct for use with ProfilerMarker.Auto.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Definition

public struct ProfilerMarker.AutoScope : IDisposable

Remarks

Use ProfilerMarker.Auto to enclose a piece of code you want to profile in using statement. Constructor of AutoScope calls ProfilerMarker.Begin and Dispose method - ProfilerMarker.End.
The contextUnityObject parameter associates the profiling sample with a specific Unity object, making it easier to identify which objects contribute to performance issues in the Profiler window.
The metadata parameter attaches additional contextual information to help distinguish different execution paths or parameter values without creating separate markers.

Examples

using Unity.Profiling;using UnityEngine;public class MySystemClass : MonoBehaviour{ ProfilerMarker simulatePerfMarker = new ProfilerMarker("MySystem.Simulate"); ProfilerMarker processItemPerfMarker = new ProfilerMarker("MySystem.ProcessItem"); public void UpdateLogic() { // Basic usage using (simulatePerfMarker.Auto()) { // ... } // With object context using (simulatePerfMarker.Auto(this)) { // ... } } public void ProcessItem(string itemType) { // With metadata using (processItemPerfMarker.Auto(itemType)) { // ... } }}