Unity.Profiling.ProfilerMarker.ProfilerMarker

Unity · Версия 2020.3 LTS · Scripting · ProfilerMarker

Unity.Profiling.ProfilerMarker.ProfilerMarker

Объявление

public ProfilerMarker(string name);

public ProfilerMarker(Unity.Profiling.ProfilerCategory category, string name);

public ProfilerMarker(Unity.Profiling.ProfilerCategory category, char* name, int nameLen);

public ProfilerMarker(Unity.Profiling.ProfilerCategory category, string name, Unity.Profiling.LowLevel.MarkerFlags flags);

public ProfilerMarker(Unity.Profiling.ProfilerCategory category, char* name, int nameLen, Unity.Profiling.LowLevel.MarkerFlags flags);

public ProfilerMarker(char* name, int nameLen);

Параметры

name Имя маркера.
category Категория профайлера.
nameLen Длина имени маркера.
flags Флаги маркера.

Описание

Создает новый маркер производительности для инструментирования кода.

Используйте ProfilerMarker, чтобы разметить фрагмент кода для Profiler и Recorder.

using Unity.Profiling;

public class MySystemClass
{
    static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");
    static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

    public void UpdateLogic()
    {
        s_PreparePerfMarker.Begin();
        // ...
        s_PreparePerfMarker.End();

        using (s_SimulatePerfMarker.Auto())
        {
            // ...
        }
    }
}

Обновлено 17 ноября 2026 г.