Version: 2020.3
특별 최적화
에셋 워크플로

에셋 로드 지표

AsyncReadManagerMetrics 클래스를 사용하여 런타임 에셋 로드 및 파일 읽기 성능을 모니터링할 수 있습니다. 이 클래스는 AsyncReadManager에서 관리하는 모든 파일 읽기 작업에 대한 데이터를 기록합니다.

The Unity Engine uses the AsyncReadManager to read most files at runtime. The files loaded with the AsyncReadManager include AssetBundles, Addressables and Resources. In addition, you can load files from scripts using AsyncReadManager.Read.

AsyncReadManagerMetrics 클래스를 사용하면 지표 수집을 활성화하고 기록된 지표 데이터를 검색해서 가져올 수 있습니다. 분석에 도움이 되도록 기록된 데이터를 필터링하고 요약할 수도 있습니다. 이 지표 정보는 에셋 로드와 관련된 문제 영역을 식별하고 변경 사항이 에셋 로드 성능에 미치는 영향을 측정하는 데 도움이 됩니다.

AsyncReadManagerMetrics 클래스는 오직 개발 빌드에서만 사용할 수 있습니다. ENABLE_PROFILER 심볼을 사용하여 #if preprocessor 지시문 내에서 AsyncReadManagerMetrics API에 대한 모든 호출을 보호해야 합니다. ENABLE_PROFILER 심볼은 개발 빌드에 대해서만 정의되어 있으므로 지표를 사용할 수 없는 빌드에서 스크립트를 컴파일할 수 있습니다. 이전 버전과의 호환성을 위해 UNITY_2020_2_OR_NEWER 심볼을 사용하여 이전 버전의 Unity에서 지표 코드를 제거할 수도 있습니다. 다음 예를 참조하십시오.

# if ENABLE_PROFILER && UNITY_2020_2_OR_NEWER
    AsyncReadManagerMetrics.StartCollectingMetrics();
# endif

지표 컬렉션 활성화

데이터를 기록하려면 지표 컬렉션을 활성화해야 합니다. 다음 방법 중 하나로 지표 컬렉션을 활성화하십시오.

참고: Unity 에디터 애플리케이션을 실행할 때 -enable-file-read-metrics 를 전달하여 플레이 모드 진입 시 컬렉션을 활성화할 수 있습니다. 하지만 에디터는 텍스처와 같은 일부 카테고리의 에셋 자체만 로드하고 플레이 모드 진입 시에는 다시 로드하지 않습니다. 파일 IO 지표를 완전히 파악하려면 애플리케이션의 개발 빌드에서 데이터를 수집해야 합니다.

지표 데이터 가져오기

Retrieve the metrics collected by the AsyncReadManagerMetrics class by calling GetMetrics. Pass an AsyncReadManagerMetrics.Flags to this function to specify whether or not to clear the metrics after retrieval. Clear the metrics to remove all the completed (including cancelled and failed) reads from the stored metrics. Clearing doesn’t affect any queued or in-process operations; you can access the metrics for unfinished operations by calling GetMetrics again after they complete. By clearing the metrics regularly, you can avoid rereading the same data and also reduce the data overhead of the system.

# if ENABLE_PROFILER && UNITY_2020_2_OR_NEWER
    AsyncReadManagerRequestMetric[] metrics 
        = AsyncReadManagerMetrics.GetMetrics(AsyncReadManagerMetrics.Flags.ClearOnRead);
# endif

Where possible, the metric data includes context information about a read operation. This information includes the AssetLoadingSubsystem that requested the read, the AssetName, and the AssetTypeID. When the AsyncReadManager doesn’t have access to this information, the value for these metrics fields is Other, empty, and zero, respectively.

참고: 현재 지원되는 것으로 알려진 에셋 타입 ID는 아래 표에 나와 있습니다. 나타날 수 있는 다른 타입 ID는 YAML 클래스 ID 레퍼런스를 참조하십시오.

타입 ID 타입 이름
28 Texture2D
117 Texture3D
89 큐브맵
43 Mesh

요약 데이터 가져오기

다음 메서드를 사용하여 AsyncReadManager 지표 요약을 가져올 수 있습니다.

예제:

# if ENABLE_PROFILER && UNITY_2020_2_OR_NEWER
    AsyncReadManagerSummaryMetrics summaryOfMetrics 
        = AsyncReadManagerMetrics.GetCurrentSummaryMetrics(AsyncReadManagerMetrics.Flags.ClearOnRead);
# endif

또는

# if ENABLE_PROFILER && UNITY_2020_2_OR_NEWER
    AsyncReadManagerRequestMetric[] metrics 
        = AsyncReadManagerMetrics.GetMetrics(AsyncReadManagerMetrics.Flags.ClearOnRead);
    AsyncReadManagerSummaryMetrics summaryOfMetrics 
        = AsyncReadManagerMetrics.GetSummaryOfMetrics(metrics);
# endif

지표에 대한 요약 데이터에는 다음의 통계가 포함됩니다.

  • 평균 대역폭
  • 평균 읽기 크기
  • 로드 시간이 가장 긴 에셋 타입
  • 읽기 횟수
  • 요청 횟수
  • 읽은 총 바이트

(See AsyncReadManagerSummaryMetrics for a complete list.)

기본적으로 요약된 통계에는 대기 열에 있거나 진행 중인 작업을 비롯하여 모든 읽기 작업이 포함됩니다. 필터를 사용하여 특별히 관심 있는 작업으로만 요약을 제한할 수 있습니다. 예를 들어 필터를 사용하여 요약된 통계를 텍스처 에셋에 대한 완료된 읽기 작업으로만 제한할 수 있습니다.

참고: 요약 통계를 계산하는 데는 처리 리소스가 필요합니다. 이러한 계산으로 인해 기록 중인 측정이 변경되지 않도록 하려면 먼저 지표를 수집하고, 분석 중인 작업이 완료된 후 요약을 가져오시기 바랍니다.

요약 필터

Use AsyncReadManagerMetricsFilters with either of these methods to specify what types of data to summarize. Any metrics that do not match a filter are excluded from the summary. You can filter with the following categories:

동일한 필터에 대해 여러 카테고리를 설정할 수 있습니다. 읽기 작업은 해당 작업의 지표가 요약에 포함되도록 모든 카테고리와 일치해야 합니다. 예를 들어 필터의 ProcessingStateSubsystem 모두에 대한 값을 지정하여 지정된 하위 시스템에서 시작된 지정된 처리 상태의 작업만 요약할 수 있습니다.

카테고리에 여러 값을 지정할 수도 있습니다. 이 경우 읽기 작업은 요약에 포함할 지표의 카테고리에 지정된 모든 값과 일치할 수 있습니다. 예를 들어 하위 시스템 카테고리에 대해 메시텍스처를 모두 지정하여 메시 에셋과 텍스처 에셋의 작업만 요약할 수 있습니다.

특별 최적화
에셋 워크플로
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961