Simpleperf
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android 스튜디오에는 Simpleperf 그래픽 프런트엔드가 포함되어 있으며 이는 CPU 프로파일러를 사용하여 CPU 활동 검사에 설명되어 있습니다.
대부분의 사용자는 Simpleperf를 직접 사용하기 보다는 이렇게 사용합니다.
명령줄을 사용하고 싶다면 Simpleperf가 Mac, Linux, Windows용 NDK에 포함된 다목적 명령줄 CPU 프로파일링 도구입니다.
전체 문서를 확인하려면 Simpleperf README로 시작하세요.
Simpleperf 도움말 및 레시피
Simpleperf를 이제 막 사용하기 시작했다면 다음과 같이 특히 유용할 수 있는 명령어를 참조하세요. 더 많은 명령어와 옵션은 Simpleperf 명령어 및 옵션 참조를 확인하세요.
실행하는 데 가장 오래 걸리는 공유 라이브러리 찾기
이 명령어를 실행하면 CPU 사이클 횟수를 기준으로 실행 시간을 가장 많이 차지하는 .so
파일을 확인할 수 있습니다. 이는 성능 분석 세션을 시작할 때 실행하기 좋은 첫 번째 명령어입니다.
$ simpleperf report --sort dso
실행하는 데 가장 오래 걸리는 함수 찾기
실행 시간을 가장 많이 차지하는 공유 라이브러리를 파악했다면 이 명령어를 실행하여 .so
파일의 함수를 실행하는 데 걸리는 시간의 비율을 확인할 수 있습니다.
$ simpleperf report --dsos library.so --sort symbol
스레드에서 소요된 시간 비율 찾기
.so
파일에 소요된 실행 시간은 여러 스레드에서 분할될 수 있습니다. 이 명령어를 실행하여 각 스레드에서 소요된 시간의 비율을 확인할 수 있습니다.
$ simpleperf report --sort tid,comm
객체 모듈에서 소요된 시간 비율 찾기
가장 많은 실행 시간을 소요한 스레드를 찾은 후에는 이 명령어를 사용하여 이러한 스레드에서 실행 시간을 가장 많이 차지하는 객체 모듈을 분리할 수 있습니다.
$ simpleperf report --tids threadID --sort dso
함수 호출과의 관련성 확인
호출 그래프는 프로파일링 세션 동안 Simpleperf가 기록하는 스택 트레이스를 시각적으로 나타냅니다.
report -g
명령어를 사용하여 호출 그래프를 인쇄하고 다른 함수에서 호출한 함수를 확인할 수 있습니다. 이는 함수 자체가 느린지, 호출된 하나 이상의 함수가 느린지를 판단하는 데 유용합니다.
$ simpleperf report -g
Python 스크립트 report.py -g
를 사용하여 함수를 표시하는 대화형 도구를 시작할 수도 있습니다. 각 함수를 클릭하여 하위 항목에서 소요된 시간을 확인할 수 있습니다.
Unity로 빌드한 앱 프로파일링
Unity로 빌드한 앱을 프로파일링한다면 다음 단계에 따라 디버그 기호로 앱을 빌드했는지 확인하세요.
- Unity Editor에서 Android 프로젝트를 엽니다.
- Android 플랫폼용 Build Settings 창에서 Development Build 옵션이 선택되어 있는지 확인합니다.
- Player Settings를 클릭하고 Stripping Level 속성을 Disabled로 설정합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2024-08-22(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-08-22(UTC)"],[],[],null,["# Simpleperf\n\nAndroid Studio includes a graphical front end to Simpleperf, documented in\n[Inspect CPU activity with CPU Profiler](https://developer.android.com/studio/profile/cpu-profiler).\nMost users will prefer to use that instead of using Simpleperf directly.\n\nIf you prefer to use the command line, Simpleperf is a versatile command-line\nCPU profiling tool included in the NDK for Mac, Linux, and Windows.\n\nFor full documentation, start with the Simpleperf [README](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/doc/README.md).\n\nSimpleperf tips and recipes\n---------------------------\n\nIf you are just starting out with Simpleperf, here are some commands that you may find\nparticularly useful. For more commands and options, see\n[Simpleperf command and options reference](/ndk/guides/simpleperf-commands).\n\n### Find which shared libraries take the longest to execute\n\nYou can run this command to see which `.so` files take up the largest percentage of execution\ntime (based on the number of CPU cycles). This is a good first command to run when starting\nyour performance analysis session. \n\n```\n$ simpleperf report --sort dso\n```\n\n### Find which functions take the longest to execute\n\nOnce you have identified which shared library takes most of the execution time, you can run this\ncommand to see the percentage of time spent executing the functions of that `.so` file. \n\n```\n$ simpleperf report --dsos library.so --sort symbol\n```\n\n### Find percentage of time spent in threads\n\nExecution time in a `.so` file can be split across multiple threads. You can run this command to\nsee the percentage of time spent in each thread. \n\n```\n$ simpleperf report --sort tid,comm\n```\n\n### Find the percentage of time spent in object modules\n\nAfter finding the threads where most of the execution time is spent, you can use this command to\nisolate the object modules taking the longest execution time on those threads. \n\n```\n$ simpleperf report --tids threadID --sort dso\n```\n\n### See how function calls are related\n\nA *call graph* provides a visual representation of a stack trace that Simpleperf records during the\nprofiling session.\n\nYou can use the `report -g` command to print a call graph to see what\nfunctions are called by other functions. This is useful to determine if a function is slow by\nitself, or if it's because one or more of the functions it calls are slow. \n\n```\n$ simpleperf report -g\n```\n\nYou can also use the Python script `report.py -g` to start an interactive tool that displays\nfunctions. You can click on each function to see how much time is spent in its children.\n\n### Profiling apps built with Unity\n\nIf you are profiling an app built with Unity, make sure to build the app with\ndebug symbols by following these steps:\n\n1. Open your Android project in the Unity Editor.\n2. In the **Build Settings** window for the Android platform, make sure the **Development Build** option is checked.\n3. Click on **Player Settings** and set the **Stripping Level** property to **Disabled**."]]