---
title: 프로파일러 카운터 시각화
product: Unity Editor
version: '6000.0'
latest_version: '7000.0'
status: This page documents version 6000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/ko-kr/engine/6000.0/manual/analysis/profiler/customizing/adding-information-code/creating-custom-counters
latest_url: https://docs.unity.com/ko-kr/engine/7000.0/manual/analysis/profiler/customizing/adding-information-code/creating-custom-counters.md
last_updated: 2026-10-30
generated_at: 2026-11-19T18:12:15.284Z
locale: ko-kr
---

# 프로파일러 카운터 시각화

> 커스텀 프로파일러 모듈에 프로파일러 카운터를 추가합니다.

프로파일러 카운터를 [코드에 추가하면](/engine/6000.0/manual/analysis/profiler/customizing/adding-information-code/add-counters-code.md) 프로파일러 창 또는 애플리케이션 빌드에서 시각화할 수 있습니다.

## 프로파일러 창 커스텀 카운터 시각화##visualizing-custom-counters-in-the-profiler-window

프로파일러 창에서 `ProfilerCounter` 또는 `ProfilerCounterValue`가 생성하는 데이터를 보려면 [커스텀 프로파일러 모듈](/engine/6000.0/manual/analysis/profiler/customizing.md)을 사용할 수 있습니다. 이는 다른 시스템 지표와의 관계를 시각적으로 인식하고 성능 문제를 신속하게 식별하는 데 도움이 될 수 있습니다.

### 코드에 지표 추가##adding-metrics-to-your-code

다음 예제에서는 GameManager 클래스가 고수준 로직을 처리하고 적에 대해 알고 있다고 가정합니다. 카운터의 값을 업데이트하려면 `Update` 또는 `LateUpdate` 메서드(적을 생성하거나 파괴하는 로직을 수행하는 시점에 따라)에서 `Sample` 메서드를 사용하여 적의 카운터 값을 프로파일러로 푸시합니다.

```lang-cs
using UnityEngine;
using Unity.Profiling;

class GameManager : MonoBehaviour
{
    적[] m_Enemies;

    void Update()
    {
        GameStats.EnemyCount.Sample(m_Enemies.Length);
    }
}
```

총알 수를 프로파일러에 전달하기 위해 이 예제에서는 총알 라이프사이클을 관리하는 셸 스크립트가 있다고 가정합니다. 그런 다음 게임의 현재 총알 흐름에 대한 정확한 정보를 제공하기 위해 `GameStats.BulletCount` 값을 `Awake` 단위로 증가시키고 `OnDestroy` 단위로 줄입니다.

```lang-cs
using UnityEngine;
using Unity.Profiling;

public class Shell : MonoBehaviour
{
    void Awake()
    {
        GameStats.BulletCount.Value += 1;
    }
    void OnDestroy()
    {
        GameStats.BulletCount.Value -= 1;
    }
}
```

> **Note:**
>
> Unity는 비개발 빌드의 `ProfilerCounter` 및 `ProfilerCounterValue`를 모두 컴파일합니다.

### 프로파일러 창 커스텀 모듈 추가##add-a-custom-module-to-the-profiler-window

시각화를 위해 빌트인 또는 새로 추가된 카운터를 선택하려면 [프로파일러 모듈 에디터](/engine/6000.0/manual/analysis/profiler/customizing/creating-custom-modules/module-editor.md)를 사용합니다. 프로파일러 모듈 에디터를 열려면 다음 단계를 따르십시오.

1. 프로파일러 창(**Window > Analysis > Profiler**)을 엽니다.
2. 창 왼쪽 상단의 Profiler Module 드롭다운을 선택합니다. 기어 아이콘을 클릭 수 프로파일러 모듈 에디터가 새 창에서 열립니다.
3. **추가**를 선택한 다음 창 오른쪽의 **사용자** 목록에서 시각화할 카운터를 선택합니다.

> **Important:**
>
> 프로파일러 창 로드된 데이터가 없으면 프로파일러 모듈 에디터를 로드할 때 생성한 카운터가 Available Counters 창에 표시되지 않습니다. 커스텀 카운터를 보려면 프로파일러로 방출된 카운터가 있는 데이터를 [캡처하거나 로드](/engine/6000.0/manual/profiler-collect-data.md)하고 프로파일러 모듈 에디터를 다시 엽니다.

그러면 프로파일러 창 다른 카운터와 함께 데이터를 볼 수 있습니다. 자세한 내용은 [커스텀 프로파일러 모듈 생성](/engine/6000.0/manual/analysis/profiler/customizing/creating-custom-modules.md)을 참고하십시오.


**Module with custom counters in Profiler Window.:**
![](/api/media?file=/engine/6000.0/media/images/profiler-window-custom-module.png)

> **Note:**
>
> 정적으로 선언된 카운터는 타입이 초기화될 때 C# 코드에서 동적으로 초기화되며 실제로 초기화되고 사용될 때까지 사용할 수 없습니다. 이는 편집 모드와 플레이 모드 모두에 적용됩니다. 카운터가 프로파일러 모듈 에디터에 표시되지 않으면 먼저 몇 프레임 동안 [프로파일러로 일부 데이터를 기록](/engine/6000.0/manual/analysis/profiler/profiling-applications/profiling-target-device.md)합니다.

## 빌드된 플레이어에서 프로파일러 카운터 시각화##visualizing-profiler-counters-in-a-built-player

빌드된 플레이어에서 프로젝트를 실행하면 프로파일러 창 액세스할 수 없습니다. 하지만 빌드된 플레이어에서 카운터를 UI 요소로 표시할 수 있습니다. 따라서 애플리케이션 빌드에 프로파일링 툴을 포함할 수 있습니다.

다음 이미지는 빌드된 플레이어의 커스텀 UI를 사용하여 씬의 왼쪽 상단에 있는 카운터를 보여줍니다.


**Tanks game with custom information overlaid:**
![](/api/media?file=/engine/6000.0/media/images/Tanks-Runtime-Stats.png)

> **Note:**
>
> 릴리스 플레이어(비개발 빌드)에서는 모든 프로파일러 카운터를 사용할 수 없습니다. [`ProfilerRecorder.Valid`](/engine/6000.0/script-reference/unity/profiling/profilerrecorder/valid.md)을 사용하여 데이터를 사용할 수 있고 프로파일러가 기록할 수 있는지 확인합니다. 또는 [`ProfilerRecorderHandle.GetAvailable`](/engine/6000.0/script-reference/unity/profiling/lowlevel/unsafe/profilerrecorderhandle/getavailable.md)을 사용하여 사용 가능한 모든 프로파일러 통계를 열거할 수도 있습니다.

### 플레이어의 카운터 값 가져오기##getting-counter-values-in-players

프로파일러 카운터는 중요한 게임 또는 엔진 시스템 지표에 대한 인사이트를 제공합니다. 지속적인 통합 설정이 있거나 테스트 플레이 중에 애플리케이션의 주요 성능 지표를 시각화하려는 경우 [`ProfilerRecorder`](/engine/6000.0/script-reference/unity/profiling/profilerrecorder.md) API를 사용하여 맞춤형 및 빌트인 프로파일러 카운터 값을 가져올 수 있습니다.

예를 들어 다음 스크립트는 프레임 시간, Mono/IL2CPP 힙 크기 및 애플리케이션이 사용하는 총 메모리를 표시합니다.

```lang-cs
using System.Collections.Generic;
using System.Text;
using Unity.Profiling;
using UnityEngine;

public class StatsScript : MonoBehaviour
{
    string statsText;
    ProfilerRecorder systemMemoryRecorder;
    ProfilerRecorder gcMemoryRecorder;
    ProfilerRecorder mainThreadTimeRecorder;

    더블 GetRecorderFrameAverage(ProfilerRecorder Recorder)
    {
        var samplesCount = recorder.Capacity;
        if (samplesCount == 0)
            return 0;

        double r = 0;
        안전하지 않음
        {
            var samples = stackalloc ProfilerRecorderSample[samplesCount];
            recorder.CopyTo(samples, samplesCount);
            for (var i = 0; i < samplesCount; ++i)
                r += samples[i].Value;
            r /= samplesCount;
        }

        return r;
    }

    void OnEnable()
    {
        systemMemoryRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Memory, "System Used Memory");
        gcMemoryRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Memory, "GC Reserved Memory");
        mainThreadTimeRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Internal, "Main Thread", 15);
    }

    void OnDisable()
    {
        systemMemoryRecorder.Dispose();
        gcMemoryRecorder.Dispose();
        mainThreadTimeRecorder.Dispose();
    }

    void Update()
    {
        var sb = new StringBuilder(500);
        sb.AppendLine($"Frame Time: {GetRecorderFrameAverage(mainThreadTimeRecorder) * (1e-6f):F1} ms");
        sb.AppendLine($"GC Memory: {gcMemoryRecorder.LastValue / (1024 * 1024)} MB");
        sb.AppendLine($"System Memory: {systemMemoryRecorder.LastValue / (1024 * 1024)} MB");
        statsText = sb.ToString();
    }

    void OnGUI()
    {
        GUI.TextArea(new Rect(10, 30, 250, 50), statsText);
    }
}
```

> **Important:**
>
> `ProfilerRecorder.Dispose`를 사용하여 `ProfilerRecorder`와 연결된 관리되지 않는 리소스를 해제합니다.

## 에디터에서 프로파일러 프레임 데이터에서 카운터 값 가져오기##getting-counter-values-from-profiler-frame-data-in-the-editor

에디터에서 프로파일러 프레임 데이터를 처리할 때 프로파일러 카운터 값을 가져오려면 [`FrameDataView`](/engine/6000.0/script-reference/unityeditor/profiling/framedataview.md) API를 사용하십시오.

다음과 같이 특정 카운터의 프레임 값을 얻기 위해 [`FrameDataView.GetCounterValueAsInt`](/engine/6000.0/script-reference/unityeditor/profiling/framedataview/getcountervalueasint.md), [`FrameDataView.GetCounterValueAsLong`](/engine/6000.0/script-reference/unityeditor/profiling/framedataview/getcountervalueaslong.md), [`FrameDataView.GetCounterValueAsFloat`](/engine/6000.0/script-reference/unityeditor/profiling/framedataview/getcountervalueasfloat.md) 및 [`FrameDataView.GetCounterValueAsDouble`](/engine/6000.0/script-reference/unityeditor/profiling/framedataview/getcountervalueasdouble.md)를 사용할 수 있습니다.

```lang-cs
using UnityEditor.Profiling;

클래스 예시
{
    static int ExtractMyCounterValue(FrameDataView frameData, string counterName)
    {
        var counterMarkerId = frameData.GetMarkerId(counterName);
        return frameData.GetCounterValueAsInt(counterMarkerId);
    }
}
```

## 추가 리소스##additional-resources

* [코드에 프로파일러 카운터 추가](/engine/6000.0/manual/analysis/profiler/customizing/adding-information-code/add-counters-code.md)
* [프로파일러 모듈 에디터 참조](/engine/6000.0/manual/analysis/profiler/customizing/creating-custom-modules/module-editor.md)
