참고: 내부 프로파일러는 지원이 중단되어 향후 Unity 버전에서 제거될 예정입니다. 대신 프로파일러 창(메뉴: Window > Analysis > Profiler)을 사용하십시오.
Unity에는 iOS 및 Android용 빌트인 프로파일러가 들어 있습니다. 30프레임마다 빌트인 프로파일러가 기기에서 실행되는 앱에서 콘솔 메시지를 발송합니다. 이 메시지는 앱의 동작 방식에 대한 인사이트를 제공합니다. 특히 앱이 CPU 또는 GPU 바운드인지 판단할 때 큰 도움이 됩니다. 앱이 CPU 바운드이면 스크립트 코드 또는 가비지 컬렉션이 병목 현상을 유발하는지도 확인할 수 있습니다. 이 페이지에는 빌트인 프로파일러의 설정 방법이 나와 있습니다.
다음은 빌트인 프로파일러에서 출력되는 정보의 예제입니다.
iPhone Unity internal profiler stats
frametime> min: 32.5 max: 34.1 avg: 33.3
cpu-player> min: 2.2 max: 4.4 avg: 3.7
batches> min: 3 max: 3 avg: 3
draw calls> min: 3 max: 3 avg: 3
tris> min: 1704 max: 1704 avg: 1704
verts> min: 5088 max: 5088 avg: 5088
dynamic batching> batched draw calls: 0 batches: 0 tris: 0 verts: 0
static batching> batched draw calls: 0 batches: 0 tris: 0 verts: 0
player-detail> physx: 0.0 animation: 0.0 culling 0.0 skinning: 0.0 batching: 0.0 render: 0.0 fixed-update-count: 0 .. 0
scripting-scripts> update: 0.0 fixedUpdate: 0.0 coroutines: 0.0
scripting-memory> information not available on non-development player configuration
모든 시간은 프레임당 밀리초 단위로 측정됩니다. 최근 30프레임에 걸친 최소, 최대, 평균 시간을 볼 수 있습니다.
프로퍼티 | 기능 |
---|---|
cpu-player | 앱이 Unity 엔진 안에서 코드를 실행하고 CPU에서 스크립트를 실행하는 데 소비하는 시간을 표시합니다. |
cpu-ogles-drv (Android 전용) | CPU에서 OpenGL ES 드라이버 코드를 실행하는 데 소요되는 시간을 표시합니다. 이 드라이버는 드로우 콜 수, 내부 렌더링 상태 변경 수, 렌더링 파이프라인 설정 및 처리된 버텍스 수를 비롯한 여러 요인의 영향을 받을 수 있습니다. |
cpu-present (Android 전용) | OpenGL ES의 presentRenderbuffer 커맨드를 실행하는 데 소요된 시간입니다. |
frametime | 앱 프레임의 전체 시간을 나타냅니다. iOS 하드웨어는 새로고침 속도가 항상 60Hz로 고정되므로, 이 프로퍼티는 항상 16.7ms(1,000ms/60Hz = 16.7ms)의 배수인 시간을 반환합니다. |
프로퍼티 | 기능 |
---|---|
tris # | 렌더링하기 위해 전송된 총 삼각형 수입니다. |
verts # | 렌더링하기 위해 전송된 총 버텍스 수입니다. 앱이 정적 지오메트리만 사용하는 경우 숫자를 10,000 이하로 유지해야 합니다. 앱이 스키닝된 지오메트리 인스턴스를 많이 사용하는 경우 훨씬 더 낮은 값을 사용해야 합니다. |
dynamic/static batching | 엔진에 의해 자동으로 배칭되는 드로우 콜, 삼각형, 버텍스의 수입니다. 이 수를 드로우 콜 및 삼각형 합계와 비교하면 씬이 배칭에 얼마나 잘 준비되어 있는지 대강 알 수 있습니다. 배칭을 개선하려면 오브젝트 간에 최대한 많은 머티리얼을 공유해야 합니다. |
player-detail 섹션에서 엔진 내부 동작에 대한 상세 내역을 확인할 수 있습니다.
프로퍼티 | 기능 |
---|---|
physx | 물리 연산에 소요된 시간입니다. |
animation | 뼈대 애니메이션에 소요된 시간입니다. |
culling | 카메라 절두체 밖에 있는 오브젝트를 컬링하는 데 소요된 시간입니다. |
skinning | 스킨드 메시에 애니메이션을 적용하는 데 소요된 시간입니다. |
batching | 지오메트리 배칭에 소요된 시간입니다. 동적 지오메트리 배칭에는 정적 지오메트리 배칭보다 훨씬 더 많은 리소스가 사용됩니다. |
render | 가시적인 오브젝트를 렌더링하는 데 소요된 시간입니다. |
fixed-update-count | 프레임 중에 실행된 최소 및 최대 FixedUpdate 수입니다. FixedUpdate가 너무 많으면 성능이 크게 저하됩니다. |
scripting-scripts 섹션에서는 Mono 런타임에서 코드를 실행하는 데 소요된 시간에 대한 상세 내역을 확인할 수 있습니다.
프로퍼티 | 기능 |
---|---|
update | 스크립트의 모든 Update() 메서드를 실행하는 데 소요된 전체 시간입니다. |
fixedUpdate | 스크립트의 모든 FixedUpdate() 메서드를 실행하는 데 소요된 전체 시간입니다. |
coroutines | 스크립트 코루틴 안에서 소비한 시간입니다. |
scripting-memory 섹션에서는 Mono 가비지 컬렉터가 메모리를 관리하는 방법에 대한 정보를 확인할 수 있습니다.
프로퍼티: | 기능: |
---|---|
allocated heap | 할당할 수 있는 총 메모리 양입니다. 힙에 특정 할당을 위한 메모리가 부족하면 가비지 컬렉션이 실행됩니다. 그래도 충분한 메모리를 확보하지 못하면 할당된 힙의 크기가 커집니다. |
used heap | allocated heap 에서 오브젝트가 현재 사용 중인 비율입니다. 이 수는 다음 가비지 컬렉션까지 새 클래스 인스턴스(구조체 아님)를 만들 때마다 커집니다. |
max number of collections | 지난 30 프레임 동안의 가비지 컬렉션 패스 횟수입니다. |
collection total duration | 지난 30프레임 동안 발생한 모든 가비지 컬렉션 패스의 총 시간(밀리초 단위)입니다. |
iOS에서는 내부 프로파일러가 기본적으로 비활성화되어 있습니다. 활성화하려면 Unity에서 생성된 Xcode 프로젝트를 열어 InternalProfiler.h
파일을 선택하고 다음 줄을
# define ENABLE_INTERNAL_PROFILER 0
다음과 같이 변경합니다.
# define ENABLE_INTERNAL_PROFILER 1
또는 iOS 플레이어 설정(메뉴: Edit > Project Settings > Player Settings에서 iOS 선택)에 액세스할 수도 있습니다. Debugging and crash reporting 섹션에서 Enable Internal Profiler (지원 중단 예정)를 활성화하십시오. 앱을 빌드할 때 Build Settings 에서 Development Build 가 활성화되어 있어야 합니다.
출력 콘솔(GDB)을 표시하려면 Xcode의 메인 메뉴에서 View > Debug Area > Activate Console 을 선택한 후 프로젝트를 실행하십시오. 그러면 Unity는 30프레임마다 콘솔 창에 통계를 출력합니다.
Android에서 내부 프로파일러를 활성화하려면 Android 플레이어 설정(메뉴: Edit > Project Settings > Player Settings에서 Android 선택)에 액세스해야 합니다. Optimization 섹션에서 Enable Internal Profiler (지원 중단 예정) 설정을 활성화하십시오. 앱을 빌드할 때 Build Settings 에서 Development Build 가 활성화되어 있어야 합니다. 그러면 기기에서 앱이 실행될 때 로그캣에 통계가 표시됩니다. 로그캣을 보려면 adb 또는 Android Debug Bridge를 설치한 후 adb logcat
셸 커맨드를 실행하십시오.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.