[AIX 성능 도구 15] Xprofiler (1) 설치, 시작, 화면 구성, 필터

핵심 정리

  • Xprofiler는 gprof와 같은 데이터(-pg로 컴파일해 만든 gmon.out)를 그래픽 함수 호출 트리로 보여 주는 X Window 도구입니다. 병렬 프로그램이면 작업마다 생긴 gmon.out.N을 모두 줘서 합계를 봅니다.
  • 실행: xprofiler a.out gmon.out [플래그]. 플래그는 gprof와 같고(-b, -s, -z, -e/-E, -f/-F, -L, -a, -c) Xprofiler 전용 -disp_max(처음 보일 함수 상자 수)가 더 있습니다.
  • 화면: 함수는 녹색 상자(높이 = 자기 CPU 시간, 너비 = 자기+자손 CPU 시간), 호출은 파란 화살표(호), 라이브러리는 클러스터 상자로 묶입니다. 처음에는 라이브러리별로 묶여 있으니 Filter > Uncluster Functions로 풉니다.
  • 상자·호·클러스터를 오른쪽 클릭하면 각 메뉴, 왼쪽 클릭하면 정보 상자가 나옵니다. 여러 gmon.out이면 평균 모드로 작업 분산(부하 불균형)을 볼 수 있습니다.
  • Filter 메뉴로 라이브러리 호출 숨기기, 함수 이름·CPU 시간·호출 횟수로 거르기, Undo, 전체 트리 다시 보기를 합니다. Utility > Locate Function By Name으로 함수를 찾습니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (내용이 같고, 5.3판은 독립된 2장, 6.1판은 프로파일링 도구 장의 한 절)
원문 Performance Tools Guide and Reference — 5.3판 2장(1144쪽), 6.1판 256287쪽
명령 /usr/bin/xprofiler (파일 세트 xprofiler)
관련 명령어 gprof, prof, tprof, cc -pg

X-Windows 성능 프로파일러(Xprofiler)는 병렬·직렬 응용 프로그램의 성능 분석을 돕는 도구입니다. 프로시저 프로파일링 정보로 응용 프로그램 안의 함수를 그래픽으로 보여 줍니다.

Xprofiler는 프로파일링 데이터를 빠르게 보여 주어 CPU를 가장 많이 쓰는 함수를 알아낼 수 있게 합니다. 그래픽 사용자 인터페이스(GUI)에서 화면을 조작해 응용 프로그램의 중요한 부분에 집중할 수도 있습니다.

이 장에서는 함수(function)라는 말을 자주 씁니다. 루틴, 서브루틴, 프로시저와 같은 뜻으로 봅니다.

영어 원문

X-Windows Performance Profiler (Xprofiler)

The X-Windows Performance Profiler (Xprofiler) tool helps you analyze your parallel or serial application's performance. It uses procedure-profiling information to construct a graphical display of the functions within your application.

X-Windows Performance Profiler (Xprofiler) provides quick access to the profiled data, which lets you identify the functions that are the most CPU-intensive. The graphical user interface (GUI) also lets you manipulate the display in order to focus on the application's critical areas.

The word function is used frequently throughout this chapter. Consider it to be synonymous with the terms routine, subroutine, and procedure.

Xprofiler 개요

Xprofiler로 직렬 응용 프로그램과 병렬 응용 프로그램을 모두 프로파일링할 수 있습니다. 직렬 응용 프로그램은 프로파일 데이터 파일을 하나, 병렬 응용 프로그램은 여러 개 만듭니다. Xprofiler로 그 프로파일링 정보를 분석합니다.

Xprofiler는 창과 보고서의 일부 기능을 원하는 대로 바꿀 수 있는 자원 변수(resource variable) 묶음을 제공합니다.

요구 사항과 제한

Xprofiler를 쓰려면 응용 프로그램을 -pg 플래그로 컴파일해야 합니다.

참고: 스레드 수준 프로파일링의 새 형식 gmon.out 파일을 만들 수 있지만 Xprofiler는 이 형식을 지원하지 않습니다. 그러므로 GPROF 환경 변수를 설정해 이전 형식의 gmon.out 파일을 만들어야 합니다. 자세한 것은 gprof 명령을 봅니다.

gprof 명령처럼 Xprofiler도 CPU(바쁜) 사용량만 분석합니다. CPU 유휴, I/O, 통신 같은 다른 정보는 주지 않습니다.

한 프로세서에서 컴파일하고 다른 프로세서에서 분석하려면, 먼저 두 프로세서의 라이브러리 구성이 적어도 응용 프로그램이 쓰는 시스템 라이브러리만큼은 비슷한지 확인해야 합니다. 예를 들어 High Performance Fortran 응용 프로그램을 서버에서 실행하고 프로파일링 데이터를 워크스테이션에서 분석하려면, High Performance Fortran 런타임 라이브러리의 수준이 같아야 하고 워크스테이션에서 Xprofiler가 알아보는 위치에 있어야 합니다. 그렇지 않으면 결과를 예측할 수 없습니다.

Xprofiler는 표본 수집으로 데이터를 모으므로, 짧게 실행되는 함수는 CPU 사용이 나타나지 않을 수 있습니다.

Xprofiler는 다중 스레드 프로그램의 개별 스레드 정보를 주지 않습니다. 모든 스레드의 활동을 합친 요약으로 보여 줍니다.

Xprofiler와 gprof 명령 비교

Xprofiler에서도 gprof 명령에서 익숙한 표 형식 보고서, 곧 평면 프로파일(Flat Profile), 호출 그래프 프로파일(Call Graph Profile), 함수 색인(Function Index) 보고서를 만들 수 있습니다.

gprof와 달리 Xprofiler는 응용 프로그램을 프로파일링하는 GUI를 제공합니다. 텍스트 보고서 대신 응용 프로그램 성능을 그래픽으로 보여 주며, 소스 문장 수준까지 프로파일링할 수 있습니다.

Xprofiler GUI에서는 gprof와 같은 명령줄 플래그를 모두 쓸 수 있고, Xprofiler에만 있는 플래그도 몇 가지 더 있습니다.

프로파일링할 응용 프로그램 컴파일하기

Xprofiler를 쓰려면 컴파일러 명령의 -pg 플래그로 응용 프로그램을 컴파일하고 링크해야 합니다.

직렬이든 병렬이든 -pg를 써야 합니다. 컴파일과 링크를 한 번에 하거나 따로 할 수 있습니다. 한 번에 컴파일하고 링크하는 예입니다.

text
cc -pg -o foo foo.c

먼저 컴파일하고 나중에 링크하는 예입니다. 컴파일은 다음과 같이 합니다.

text
cc -pg -c foo.c

링크는 다음과 같이 합니다.

text
cc -pg -o foo foo.o

컴파일과 링크를 따로 할 때는 두 명령 모두에 -pg 플래그를 줘야 합니다.

-pg 플래그로 컴파일하고 링크하면, 실행할 때 CPU 사용 데이터가 하나 이상의 출력 파일에 쓰입니다. 직렬 응용 프로그램은 기본으로 gmon.out이라는 파일 하나만 만듭니다. 병렬 응용 프로그램은 실행 중인 작업(task)마다 파일을 하나씩 만듭니다. 출력 파일끼리 덮어쓰지 않도록 각 gmon.out 파일 뒤에 작업 ID가 붙습니다(예: gmon.out.10).

참고: -pg 플래그는 -p와 -g 컴파일 플래그를 합친 것이 아닙니다.

병렬 응용 프로그램의 성능을 온전히 보려면 Xprofiler에 응용 프로그램을 적재할 때 gmon.out 파일을 모두 지정해야 합니다. gmon.out 파일을 여럿 지정하면 Xprofiler는 각 파일의 프로파일 정보를 합해 보여 줍니다.

Xprofiler GUI에서 포함된(included) 함수를 볼 수 있습니다. 포함된 함수를 보려면 응용 프로그램을 -g 플래그로도 컴파일해야 합니다.

소스 문장 수준 프로파일링에도 -pg에 더해 -g 플래그가 필요합니다.

영어 원문

Xprofiler overview

Xprofiler lets you profile both serial and parallel applications. Serial applications generate a single profile data file, while a parallel application produces multiple profile data files. You can use Xprofiler to analyze the resulting profiling information.

Xprofiler provides a set of resource variables that let you customize some of the features of the Xprofiler window and reports.

Requirements and limitations

To use Xprofiler, your application must be compiled with the -pg flag.

Note: You can generate a new format of the thread-level profiling gmon.out files. Xprofiler does not support this new format, so you must set the GPROF environment variable to ensure that you produce the previous format of the gmon.out files. For more information, please see the gprof Command.

Like the gprof command, Xprofiler lets you analyze CPU (busy) usage only. It does not provide other kinds of information, such as CPU idle, I/O, or communication information.

If you compile your application on one processor, and then analyze it on another, you must first make sure that both processors have similar library configurations, at least for the system libraries used by the application. For example, if you run a High Performance Fortran application on a server, then try to analyze the profiled data on a workstation, the levels of High Performance Fortran run-time libraries must match and must be placed in a location on the workstation that Xprofiler recognizes. Otherwise, Xprofiler produces unpredictable results.

Because Xprofiler collects data by sampling, functions that run for a short amount of time might not show any CPU use.

Xprofiler does not give you information about the specific threads in a multi-threaded program. Xprofiler presents the data as a summary of the activities of all the threads.

Related concepts

“Compiling applications to be profiled” To use Xprofiler, you must compile and link your application with the -pg flag of the compiler command.

Comparing Xprofiler and the gprof command

With Xprofiler, you can produce the same tabular reports that you might be accustomed to seeing with the gprof command. As with gprof, you can generate the Flat Profile, Call Graph Profile, and Function Index reports.

Unlike gprof, Xprofiler provides a GUI that you can use to profile your application. Xprofiler generates a graphical display of your application's performance, as opposed to a text-based report. Xprofiler also lets you profile your application at the source statement level.

From the Xprofiler GUI, you can use all of the same command line flags as gprof, as well as some additional flags that are unique to Xprofiler.

Compiling applications to be profiled

To use Xprofiler, you must compile and link your application with the -pg flag of the compiler command.

You must use the -pg regardless of whether you are compiling a serial or parallel application. You can compile and link your application all at once, or perform the compile and link operations separately. The following is an example of how you would compile and link all at once:

text
cc -pg -o foo foo.c

The following is an example of how you would first compile your application and then link it. To compile, do the following:

text
cc -pg -c foo.c

To link, do the following:

text
cc -pg -o foo foo.o

Notice that when you compile and link separately, you must use the -pg flag with both the compile and link commands.

The -pg flag compiles and links the application so that when you run it, the CPU usage data is written to one or more output files. For a serial application, this output consists of only one file called gmon.out, by default. For parallel applications, the output is written into multiple files, one for each task that is running in the application. To prevent each output file from overwriting the others, the task ID is appended to each gmon.out file (for example: gmon.out.10).

Note: The -pg flag is not a combination of the -p and the -g compiling flags.

To get a complete picture of your parallel application's performance, you must indicate all of its gmon.out files when you load the application into Xprofiler. When you specify more than one gmon.out file, Xprofiler shows you the sum of the profile information contained in each file.

The Xprofiler GUI lets you view included functions. Your application must also be compiled with the -g flag in order for Xprofiler to display the included functions.

In addition to the -pg flag, the -g flag is also required for source-statement profiling.

Related concepts

Requirements and limitations To use Xprofiler, your application must be compiled with the -pg flag.

Xprofiler 설치 정보

Xprofiler의 시스템 요구 사항, 제한, 설치 방법과, 설치할 때 만들어지는 파일과 디렉터리입니다.

설치 전 정보

Xprofiler의 하드웨어·소프트웨어 요구 사항은 다음과 같습니다.

소프트웨어 요구 사항

  • X Window System
  • CDE(Common Desktop Environment)에서 Xprofiler를 실행하려면 X11.Dt.lib 4.2.1.0 이상

디스크 공간 요구 사항

  • /usr 디렉터리에 512바이트 블록 6500개

제한:

모든 노드에 Xprofiler를 설치할 필요는 없지만, 소프트웨어 라이브러리 수준이 같은 노드 묶음마다 적어도 한 노드에는 설치하는 것이 좋습니다.

한 프로세서에서 gmon.out 파일을 모으고 다른 프로세서에서 Xprofiler로 분석하려면, 두 프로세서의 일부 공유(시스템) 라이브러리가 다를 수 있다는 것을 알아 둡니다. 그러면 공유 라이브러리의 함수 호출 트리가 다르게 보일 수 있습니다.

Xprofiler 설치하기

Xprofiler는 installp 명령이나 SMIT으로 설치합니다.

installp 명령으로 설치하려면 다음을 입력합니다.

text
installp -a -I -X -d device_name xprofiler

SMIT으로 설치하려면 다음과 같이 합니다.

  1. (네트워크로 설치하지 않으면) 설치 장치에 배포 매체를 넣습니다.
  2. 다음을 입력합니다. 소프트웨어 설치용 SMIT 화면이 열립니다.
text
smit install_latest
  1. List를 누릅니다. 소프트웨어를 읽을 INPUT 장치와 디렉터리 목록이 나옵니다.
  2. 목록에서 설치 장치나 디렉터리를 고릅니다. 원래 SMIT 화면에 고른 것이 표시됩니다.
  3. Do를 누릅니다. 기본 설치 매개변수가 나옵니다.
  4. SOFTWARE to install 필드에 다음을 입력하고 Enter를 누릅니다.
text
xprofiler
  1. 설치가 끝나면 F10을 눌러 SMIT을 끝냅니다.

Xprofiler가 만드는 디렉터리와 파일

Xprofiler를 설치하면 다음 디렉터리와 파일이 만들어집니다.

디렉터리·파일 설명
/usr/lib/nls/msg/En_US/xprofiler.cat, /usr/lib/nls/msg/en_US/xprofiler.cat, /usr/lib/nls/msg/C/xprofiler.cat Xprofiler 메시지 카탈로그
/usr/xprofiler/defaults/Xprofiler.ad X-Windows와 Motif 자원 변수의 기본값 파일
/usr/xprofiler/bin/.startup_script Xprofiler 시작 스크립트
/usr/xprofiler/bin/xprofiler Xprofiler 실행 파일
/usr/xprofiler/help/en_US/xprofiler.sdl, /usr/xprofiler/help/en_US/xprofiler_msg.sdl, /usr/xprofiler/help/en_US/graphics 온라인 도움말
/usr/xprofiler/READMES/xprofiler.README 설치 readme 파일
/usr/xprofiler/samples 예제 프로그램 디렉터리

설치하면서 다음 심볼릭 링크를 만듭니다.

링크 가리키는 곳
/usr/lpp/X11/lib/X11/app-defaults/Xprofiler /usr/xprofiler/defaults/Xprofiler.ad
/usr/bin/xprofiler /usr/xprofiler/bin/.startup_script
영어 원문

Xprofiler installation information

This section contains Xprofiler system requirements, limitations, and information about installing Xprofiler. It also lists the files and directories that are created by installing Xprofiler.

Preinstallation information

Review the following requirements before you install Xprofiler.

The following are hardware and software requirements for Xprofiler:

Software requirements

  • X Window System

  • X11.Dt.lib 4.2.1.0 or later, if you want to run Xprofiler in the Common Desktop Environment (CDE)

Disk space requirements

  • 6500 512-byte blocks in the /usr directory

Limitations:

Although it is not required to install Xprofiler on every node, it is advisable to install it on at least one node in each group of nodes that have the same software library levels.

If users plan to collect a gmon.out file on one processor and then use Xprofiler to analyze the data on another processor, they should be aware that some shared (system) libraries might not be the same on the two processors. This situation might result in different function-call tree displays for shared libraries.

Installing Xprofiler

There are two methods to install Xprofiler. One method is by using the installp command. The other is by using SMIT.

Using the installp command:

You can use the installp command to install Xprofiler.

To install Xprofiler, type:

text
installp -a -I -X -d device_name xprofiler

Using SMIT:

You can use SMIT to install Xprofiler.

To install Xprofiler using SMIT, do the following:

  1. Insert the distribution media in the installation device (unless you are installing over a network).

  2. Enter the following:

text
smit install_latest

This command opens the SMIT panel for installing software.

  1. Press List. A panel lists the available INPUT devices and directories for software.

  2. Select the installation device or directory from the list of available INPUT devices. The original SMIT panel indicates your selection.

  3. Press Do. The SMIT panel displays the default installation parameters.

  4. Type:

text
xprofiler

in the SOFTWARE to install field and press Enter.

  1. Once the installation is complete, press F10 to exit SMIT.

Directories and files created by Xprofiler

Review the follow information about directories and files that are created when you install Xprofiler.

Installing Xprofiler creates the directories and files shown in the following table:

Table 5. Xprofiler directories and files installed

  • /usr/lib/nls/msg/En_US/xprofiler.cat /usr/lib/nls/msg/en_US/xprofiler.cat /usr/lib/nls/msg/C/xprofiler.cat — Message catalog for Xprofiler
  • /usr/xprofiler/defaults/Xprofiler.ad — Defaults file for X-Windows and Motif resource variables
  • /usr/xprofiler/bin/.startup_script — Startup script for Xprofiler
  • /usr/xprofiler/bin/xprofiler — Xprofiler exec file
  • /usr/xprofiler/help/en_US/xprofiler.sdl /usr/xprofiler/help/en_US/xprofiler_msg.sdl /usr/xprofiler/help/en_US/graphics — Online help
  • /usr/xprofiler/READMES/xprofiler.README — Installation readme file
  • /usr/xprofiler/samples — Directory containing sample programs

The following symbolic link is made during the installation process of Xprofiler:

  • /usr/lpp/X11/lib/X11/app-defaults/Xprofiler — /usr/xprofiler/defaults/Xprofiler.ad
  • /usr/bin/xprofiler — /usr/xprofiler/bin.startup_script

Xprofiler GUI 시작하기

Xprofiler를 시작하려면 명령줄에 xprofiler 명령을 입력합니다.

바이너리 실행 파일, 하나 이상의 프로파일 데이터 파일, 그리고 선택으로 하나 이상의 플래그를 지정해야 합니다. 방법은 두 가지입니다. xprofiler 명령과 함께 명령줄에 파일과 플래그를 주거나, xprofiler 명령만 입력한 다음 GUI에서 파일과 플래그를 지정합니다.

병렬 응용 프로그램을 프로파일링하면 실행할 때 작업마다 gmon.out 파일이 만들어지므로 파일이 여럿 생깁니다. 직렬 응용 프로그램도 여러 번 실행한 결과를 합쳐 보고 싶을 때가 있습니다. 이런 경우 프로파일링할 프로파일 데이터 파일을 모두 Xprofiler에 지정해야 합니다.

Xprofiler를 시작하면서 바이너리 실행 파일, 프로파일 데이터 파일, 플래그를 지정하려면 다음을 입력합니다.

text
xprofiler a.out gmon.out... [flag...]

a.out은 바이너리 실행 파일, gmon.out...은 프로파일 데이터 파일 이름(하나 이상), flag...는 다음 절에 나오는 Xprofiler 명령줄 플래그(하나 이상)입니다.

Xprofiler 명령줄 플래그

xprofiler 명령에는 gprof와 같은 명령줄 플래그와, Xprofiler 전용 플래그 하나(-disp_max)를 줄 수 있습니다.

명령줄 플래그로 Xprofiler가 프로파일링 결과를 보여 주는 방식을 제어합니다. 다음 플래그는 명령줄에서도, Xprofiler GUI에서도 지정할 수 있습니다(아래 "GUI에서 명령줄 옵션 지정하기" 참고).

플래그 하는 일 예
-a 소스 코드와 라이브러리 파일을 찾을 다른 경로를 더하거나 현재 경로 검색 순서를 바꿉니다. 기본 파일 경로를 "at" 기호(@)로 나타내, 다른 경로를 기본 경로보다 먼저 찾게 할 수 있습니다. pathA, 기본 경로, pathB 순서로 찾으려면 xprofiler -a pathA:@:pathB
-b File 메뉴의 Save As로 평면 프로파일, 호출 그래프 프로파일, 함수 색인 보고서를 파일에 쓸 때 필드 설명을 빼고 씁니다. xprofiler -b a.out gmon.out
-c 지정한 구성 파일을 적재합니다. 명령줄에서 쓰면 그 파일 이름이 Load Files Dialog 창의 Configuration File (-c): 필드와 Load Configuration File Dialog 창의 Selection 필드에 나옵니다. 명령줄에 -c와 -disp_max를 함께 주면 -disp_max는 무시되지만, 그 값은 다음에 Load Files Dialog 창을 열 때 Initial Display (-disp_max): 필드에 나옵니다. 구성 파일 myfile.cfg를 적재하려면 xprofiler a.out gmon.out -c myfile.cfg
-disp_max 함수 호출 트리에 처음 보여 줄 함수 상자 수를 정합니다. 0~5000 사이의 정수이며, CPU를 가장 많이 쓰는 함수부터 그 수만큼 보여 줍니다. 예를 들어 50이면 CPU 사용량이 가장 큰 함수 50개의 상자를 보여 줍니다. 그 뒤 Filter 메뉴로 보이는 상자 수를 바꿀 수 있습니다. 보고서 내용에는 영향이 없습니다. xprofiler -disp_max 50 a.out gmon.out
-e 함수 호출 트리에서 지정한 함수의 상자를 흐리게 표시하고, 호출 그래프 프로파일 보고서에서 그 함수의 항목 수를 제한합니다. 지정하지 않은 함수가 부르지 않은 자손 함수에도 적용됩니다. 트리에서 상자는 비활성(흐림)으로 바뀌고 크기와 이름표 내용은 그대로입니다. 보고서에서 지정한 함수의 항목은 다른 함수의 자식으로 나올 때, 또는 지정하지 않은 함수를 부모로 하나 이상 가진 함수의 부모로 나올 때만 나오며 내용은 그대로입니다. 지정한 함수의 자손 항목은 지정하지 않은 함수가 적어도 하나 부르지 않으면 나오지 않습니다. foo와 bar, 그 자손의 상자를 흐리게 하려면 xprofiler -e foo -e bar a.out gmon.out
-E 지정한 함수의 상자 모양과 이름표 정보를 바꾸고, 호출 그래프 프로파일 보고서에서 그 함수의 항목 수를 제한하며 CPU 데이터를 바꿉니다. 지정하지 않은 함수가 부르지 않은 자손에도 적용됩니다. 트리에서 상자는 비활성이 되고 가장 작은 정사각형으로 바뀌며 이름표의 CPU 시간이 0으로 나옵니다. 지정한 함수가 쓴 CPU 시간은 모든 조상 함수 상자 이름표의 왼쪽 CPU 합계에서 빠집니다. 보고서에서 지정한 함수의 항목은 -e와 같은 경우에만 나오며, 그때 self와 descendants 열은 0이 됩니다. 또 그 함수의 descendants 시간이 프로파일링한 함수의 descendants 시간에서 빠지므로 대부분 함수의 % time 값이 바뀝니다. xprofiler -E foo -E bar a.out gmon.out
-f 지정한 함수와 그 자손을 뺀 모든 함수 상자를 흐리게 표시하고, 호출 그래프 프로파일 보고서에서 지정하지 않은 함수와 자손이 아닌 함수의 항목 수를 제한합니다. -e보다 우선합니다. 트리에서 지정한 함수와 자손을 뺀 상자는 비활성이 되며 크기와 이름표는 그대로입니다. 보고서에서 지정하지 않았거나 자손이 아닌 함수의 항목은 지정한 함수나 그 자손의 부모 또는 자식일 때만 나오며 내용은 그대로입니다. xprofiler -f foo -f bar a.out gmon.out
-F 지정한 함수와 그 자손을 뺀 모든 함수 상자의 모양과 이름표를 바꾸고, 호출 그래프 프로파일 보고서에서 지정하지 않은 함수와 자손이 아닌 함수의 항목 수를 제한하며 CPU 데이터를 바꿉니다. -E보다 우선합니다. 해당 상자는 비활성이 되고 가장 작은 정사각형으로 바뀌며 이름표의 CPU 시간이 0으로 나옵니다. 보고서에서 그런 항목은 지정한 함수나 그 자손의 부모 또는 자식일 때만 나오며 self와 descendants 열은 0이 되므로, 대부분 함수의 % time 값이 바뀝니다. xprofiler -F foo -F bar a.out gmon.out
-h, -? xprofiler 명령의 사용법을 보여 줍니다. xprofiler -h
-L 공유 라이브러리를 찾을 다른 경로 이름을 지정합니다. 경로를 여럿 지정하려면 GUI의 File 메뉴에서 Set File Search Path를 씁니다("파일 검색 순서 정하기" 참고). xprofiler -L /lib/profiled/libc.a:shr.o
-s Xprofiler를 시작할 때 gmon.out 파일을 여럿 지정했으면 gmon.sum 프로파일 데이터 파일을 만듭니다. gmon.sum은 지정한 모든 프로파일 파일의 정보를 합한 것입니다. gmon.out 하나만 지정하면 gmon.sum의 내용은 gmon.out과 같습니다. xprofiler -s a.out gmon.out.1 gmon.out.2 gmon.out.3
-z CPU 사용량도 호출 횟수도 0인 함수까지 평면 프로파일, 호출 그래프 프로파일, 함수 색인 보고서에 넣습니다. 정의가 든 파일을 -pg 플래그로 컴파일하지 않았으면 호출 횟수가 없으며, 시스템 라이브러리 파일에서 흔합니다. xprofiler -z a.out gmon.out

-h의 사용법 출력은 다음과 같습니다.

text
xprofiler [program] [-b] [-h] [-s] [-z] [-a path(s)] [-c file] [-L pathname] [[-e function]...] [[-E function]...] [[-f function]...] [[-F function]...] [-disp_max number_of_functions] [[gmon.out]...]

xprofiler 명령을 입력하면 Xprofiler 주 창이 열리고 응용 프로그램의 데이터를 보여 줍니다.

Xprofiler GUI에서 파일 적재하기

xprofiler 명령만 입력했으면 Xprofiler GUI에서 실행 파일, 하나 이상의 프로파일 데이터 파일, 플래그를 지정할 수 있습니다. File 메뉴의 Load File을 씁니다.

xprofiler -h나 xprofiler -?를 입력하면 사용법을 보여 주고 끝납니다.

xprofiler 명령만 입력하면 Xprofiler 주 창이 열리지만, 실행 파일이나 프로파일 데이터 파일을 지정하지 않았으므로 창은 비어 있습니다.

GUI 메뉴 막대에서 File, Load File을 고릅니다. Load Files Dialog 창이 나옵니다.

Load Files Dialog 창에서 응용 프로그램의 실행 파일과 그에 맞는 프로파일 데이터(gmon.out) 파일을 지정합니다. 파일을 적재할 때 프로파일링 데이터를 보여 주는 방식을 제어하는 여러 명령줄 옵션도 지정할 수 있습니다.

프로파일링할 응용 프로그램의 파일을 적재하려면 다음을 지정해야 합니다.

  • 바이너리 실행 파일
  • 하나 이상의 프로파일 데이터 파일

선택으로 하나 이상의 명령줄 플래그도 지정할 수 있습니다.

바이너리 실행 파일:

Load Files Dialog 창의 Binary Executable File: 영역에서 바이너리 실행 파일을 지정합니다. Directories와 Files 선택 상자의 스크롤 막대로 적재할 실행 파일을 찾습니다. 기본으로 Xprofiler를 부른 디렉터리의 모든 파일이 Files 선택 상자에 나옵니다. 실행 파일을 쉽게 찾도록 Filter 단추가 있어, Files 선택 상자에 나오는 파일을 특정 디렉터리나 특정 유형으로 제한합니다.

프로파일 데이터 파일:

Load Files Dialog 창의 gmon.out Profile Data File(s) 영역에서 하나 이상의 프로파일 데이터 파일을 지정합니다.

xprofiler 명령으로 시작할 때 프로파일 데이터 파일 이름을 꼭 줄 필요는 없습니다. 주지 않으면 Xprofiler가 디렉터리에서 gmon.out 파일을 찾아, 있으면 Selection 필드에 기본값으로 넣습니다. 그러면 지정한 바이너리 실행 파일과 관계없는 파일이라도 입력으로 씁니다. 잘못된 데이터를 보여 주게 되므로 이 필드에 올바른 파일을 넣는 것이 중요합니다. 쓰려는 파일 이름이 Selection 필드의 것과 다르면 올바른 이름으로 바꿔야 합니다.

Directories와 Files 선택 상자의 스크롤 막대로 프로파일 데이터 파일을 찾습니다. 파일 이름이 꼭 gmon.out일 필요는 없고, 여럿을 지정할 수 있습니다. 이 영역에도 Filter 단추가 있습니다.

GUI에서 명령줄 옵션 지정하기:

Load Files Dialog 창의 Command Line Options 영역에서 명령줄 플래그를 지정합니다. 뜻은 위 명령줄 플래그와 같고, GUI에서의 입력 방식과 추가 동작은 다음과 같습니다.

플래그 GUI에서 지정하는 방법과 추가 동작
-a (필드) Alt File Search Path(s) (-a) 필드에 pathA:@:pathB처럼 입력합니다. OK를 누르면 바꾼 내용이 Alt File Search Path Dialog 창의 Enter Alt File Search Paths: 필드에도 반영되고, 두 창이 함께 열려 있으면 반대 방향으로도 반영됩니다. 두 창이 함께 열려 있을 때 Load Files Dialog 창에서 OK나 Cancel을 누르면 두 창이 모두 닫힙니다. Reset을 누르면 창을 열었을 때의 상태로 돌아갑니다.
-b (단추) 단추를 눌린 상태로 두면 저장한 보고서에서 필드 설명을 뺍니다.
-c (필드) Configuration File (-c) 필드에 myfile.cfg처럼 입력합니다. 명령줄의 -c나 앞서 적재한 구성 파일의 이름이 필드에 나옵니다. Load Configuration File Dialog 창과 함께 열려 있으면 거기서 지정한 파일 이름도 여기에 나옵니다. Configuration File과 Initial Display 필드를 모두 채우면 Initial Display 값은 무시되지만 다음에 창을 열 때 남아 있습니다. Reset을 누르면 창을 열었을 때의 파일 이름으로 돌아갑니다.
-disp_max (필드) Init Display (-disp_max) 필드에 50처럼 입력합니다.
-e (필드) Exclude Routines (-e) 필드에 foo bar처럼 입력합니다. 함수 여러 개는 공백으로 구분합니다.
-E (필드) Exclude Routines (-E) 필드에 입력합니다. 함수 여러 개는 공백으로 구분합니다.
-f (필드) Include Routines (-f) 필드에 foo bar처럼 입력합니다. 함수 여러 개는 공백으로 구분합니다.
-F (필드) Include Routines (-F) 필드에 foo bar처럼 입력합니다. 함수 여러 개는 공백으로 구분합니다.
-L (필드) 공유 객체를 찾을 다른 경로 이름(예: /lib/profiled/libc.a:shr.o)을 입력합니다. 경로를 여럿 지정하려면 File 메뉴의 Set File Search Path를 씁니다.
-s (단추) 단추를 눌린 상태로 두면 gmon.sum 파일을 만듭니다.
-z (단추) 단추를 눌린 상태로 두면 CPU 사용량과 호출 횟수가 0인 함수도 보고서에 넣습니다.

바이너리 실행 파일, 프로파일 데이터 파일, 쓸 명령줄 플래그를 지정한 뒤 OK를 누르면 변경을 저장하고 창을 닫습니다. Xprofiler가 응용 프로그램을 적재해 성능 데이터를 보여 줍니다.

파일 검색 순서 정하기

File 메뉴의 Set File Search Paths로 Xprofiler가 라이브러리 파일과 소스 코드 파일을 찾을 곳을 정할 수 있습니다. 기본으로 Xprofiler는 기본 경로를 먼저 찾고, 지정한 다른 경로를 그다음에 찾습니다.

기본 경로:

  • 라이브러리 파일은 지정한 gmon.out 파일에 기록된 경로를 씁니다. -L 플래그를 쓰면 그 경로를 대신 씁니다. 참고: -L 플래그로는 경로를 하나만 지정할 수 있고 한 번만 쓸 수 있습니다.
  • 소스 코드 파일은 지정한 a.out 파일에 기록된 경로를 씁니다.

다른 경로:

다른 경로는 File 메뉴의 Set File Search Paths로 지정합니다. 라이브러리 파일은 모든 방법이 실패하면 실행 파일에 연결된 LIBPATH 환경 변수의 경로까지 찾습니다.

다른 경로를 지정하려면 다음과 같이 합니다.

  1. File 메뉴에서 Set File Search Paths를 고릅니다. Alt File Search Path Dialog 창이 나옵니다.
  2. Enter Alt File Search Path(s) 필드에 경로 이름을 입력합니다. 경로를 여럿 지정하려면 콜론(:)이나 공백으로 구분합니다.
    • "at" 기호(@)로 기본 파일 경로를 나타내 다른 경로를 기본 경로보다 먼저 찾게 할 수 있습니다. 예를 들어 pathA, 기본 경로, pathB 순서로 찾으려면 pathA:@:pathB를 입력합니다.
    • 다른 경로에 @를 쓰면 Alt File Search Path Dialog 창의 두 단추가 비활성이 되어 검색 순서에 영향을 주지 않습니다.
  3. OK를 누릅니다. 입력한 경로가 다른 경로가 됩니다.

검색 순서 바꾸기:

  1. File 메뉴에서 Set File Search Paths를 고릅니다.
  2. 다른 경로를 먼저 찾으려면 Check alternative path(s) first 단추를 누릅니다.
  3. OK를 누릅니다. 검색 순서가 다른 경로 → 기본 경로 → LIBPATH의 경로(라이브러리 파일만)로 바뀝니다.

기본 순서로 되돌리려면 1~3단계를 되풀이하되 2단계에서 Check default path(s) first 단추를 누릅니다.

다른 경로나 LIBPATH의 경로에서 파일을 찾으면, 그 경로는 현재 Xprofiler 세션 동안(세션을 끝내거나 새 데이터를 적재할 때까지) 그 파일의 기본 경로가 됩니다.

영어 원문

Starting the Xprofiler GUI

To start Xprofiler, enter the xprofiler command on the command line.

You must also specify the binary executable file, one or more profile data files, and optionally, one or more flags, which you can do in one of two ways. You can either specify the files and flags on the command line along with the xprofiler command, or you can enter the xprofiler command alone, then specify the files and flags from within the GUI.

You will have more than one gmon.out file if you are profiling a parallel application, because a gmon.out file is created for each task in the application when it is run. If you are running a serial application, there might be times when you want to summarize the profiling results from multiple runs of the application. In these cases, you must specify each of the profile data files you want to profile with Xprofiler.

To start Xprofiler and specify the binary executable file, one or more profile data files, and one or more flags, type:

text
xprofiler a.out gmon.out... [flag...]

where: a.out is the binary executable file, gmon.out... is the name of your profile data file (or files), and flag... is one or more of the flags listed in the following section on Xprofiler command-line flags.

Xprofiler command line flags

You can specify the same command-line flags with the xprofiler command that you do with gprof, as well as one additional flag (-disp_max), which is specific to Xprofiler.

The command line flags let you control the way Xprofiler displays the profiled output.

You can specify the flags in Table 6 from the command line or from the Xprofiler GUI (see Specifying command line options (from the GUI) for more information).

Table 6. Xprofiler command-line flags

Use this flag: To: For example:
-a Add alternative paths to search for source code and library files, or changes the current path search order. When using this flag, you can use the "at" symbol (@) to represent the default file path, in order to specify that other paths be searched before the default path. To set an alternative file search path so that Xprofiler searches pathA, the default path, then pathB, type: xprofiler -a pathA:@:pathB
-b Suppress the printing of the field descriptions for the Flat Profile, Call Graph Profile, and Function Index reports when they are written to a file with the Save As option of the File menu. Type: xprofiler -b a.out gmon.out
-c Load the specified configuration file. If this flag is used on the command line, the configuration file name specified with it will appear in the Configuration File (-c): text field in Load Files Dialog window and in the Selection field of the Load Configuration File Dialog window. When both the -c and -disp_max flags are specified on the command line, the -disp_max flag is ignored, but the value that was specified with it will appear in the Initial Display (-disp_max): field in the Load Files Dialog window the next time this window is opened. To load the configuration file myfile.cfg, type: xprofiler a.out gmon.out -c myfile.cfg

-disp_max Set the number of function boxes that Xprofiler initially displays in the function call tree. The value supplied with this flag can be any integer between 0 and 5000. Xprofiler displays the function boxes for the most CPU-intensive functions through the number you specify. For example, if you specify 50, Xprofiler displays the function boxes for the 50 functions in your program with the highest CPU usage. After this, you can change the number of function boxes that are displayed using the Filter menu options. This flag has no effect on the content of any of the Xprofiler reports. To display the function boxes for the 50 most CPU-intensive functions in the function call tree, type: xprofiler

text
-disp_max 50 a.out gmon.out

-e Deemphasize the general appearance of the function box for the specified function in the function call tree, and limits the number of entries for this function in the Call Graph Profile report. This also applies to the specified function's descendants, as long as they have not been called by non-specified functions.

In the function call tree, the function box for the specified function is made unavailable. The box size and the content of the label remain the same. This also applies to descendant functions, as long as they have not been called by non-specified functions.

In the Call Graph Profile report, an entry for a specified function only appears where it is a child of another function, or as a parent of a function that also has at least one non-specified function as its parent. The information for this entry remains unchanged. Entries for descendants of the specified function do not appear unless they have been called by at least one non-specified function in the program. To deemphasize the appearance of the function boxes for foo and bar and their qualifying descendants in the function call tree, and limit their entries in the Call Graph Profile report, type: xprofiler -e

text
foo -e bar a.out gmon.out

Table 6. Xprofiler command-line flags (continued)

Use this flag: To: For example:
-E Change the general appearance and label information of the function box for the specified function in the function call tree. This flag also limits the number of entries for this function in the Call Graph Profile report, and changes the CPU data associated with them. These results also apply to the specified function's descendants, as long as they have not been called by non-specified functions in the program. In the function call tree, the function box for the specified function is made unavailable, and the box size and shape also changes so that it appears as a square of the smallest permitted size. In addition, the CPU time shown in the function box label, appears as 0. The same applies to function boxes for descendant functions, as long as they have not been called by non-specified functions. This flag also causes the CPU time spent by the specified function to be deducted from the CPU total on the left in the label of the function box for each of the specified function's ancestors. In the Call Graph Profile report, an entry for the specified function only appears where it is a child of another function, or as a parent of a function that also has at least one non-specified function as its parent. When this is the case, the time in the self and descendants columns for this entry is set to 0. In addition, the amount of time that was in the descendants column for the specified function is subtracted from the time listed under the descendants column for the profiled function. As a result, be aware that the value listed in the % time column for most profiled functions in this report will change. To change the display and label information for foo and bar, as well as their qualifying descendants in the function call tree, and limit their entries and data in the Call Graph Profile report, type: xprofiler -E foo -E bar a.out gmon.out

-f Deemphasize the general appearance of all function boxes in the function call tree, except for that of the specified function and its descendants. In addition, the number of entries in the Call Graph Profile report for the non-specified functions and non-descendant functions is limited. The -f flag overrides the -e flag.

In the function call tree, all function boxes except for that of the specified function and its descendants are made unavailable. The size of these boxes and the content of their labels remain the same. For the specified function and its descendants, the appearance of the function boxes and labels remain the same.

In the Call Graph Profile report, an entry for a non-specified or non-descendant function only appears where it is a parent or child of a specified function or one of its descendants. All information for this entry remains the same. To deemphasize the display of function boxes for all functions in the function call tree except for foo, bar, and their descendants, and limit their types of entries in the Call Graph Profile report, type: xprofiler -f foo -f bar a.out

text
gmon.out

-F Change the general appearance and label information of all function boxes in the function call tree except for that of the specified function and its descendants. In addition, the number of entries in the Call Graph Profile report for the non-specified and non-descendant functions is limited, and the CPU data associated with them is changed. The -F flag overrides the -E flag.

In the function call tree, the function box for the specified function are made unavailable, and its size and shape also changes so that it appears as a square of the smallest permitted size. In addition, the CPU time shown in the function box label, appears as 0.

In the Call Graph Profile report, an entry for a non-specified or non-descendant function only appears where it is a parent or child of a specified function or one of its descendants. When this is the case, the time in the self and descendants columns for this entry is set to 0. As a result, be aware that the value listed in the % time column for most profiled functions in this report will change. To change the display and label information of the function boxes for all functions except the functions foo and bar and their descendants, and limit their types of entries and data in the Call Graph Profile report, type: xprofiler -F

text
foo -F bar a.out gmon.out

Table 6. Xprofiler command-line flags (continued)

Use this flag: To: For example:
-h │-? Display the xprofiler command's usage statement. xprofiler -h Usage: xprofiler [program] [-b] [-h] [-s] [-z] [-a path(s)] [-c file] [-L pathname] [[-e function]...] [[-E function]...] [[-f function]...] [[-F function]...] [-disp_max number_of_functions] [[gmon.out]...]
-L Specify an alternative path name for locating shared libraries. If you plan to specify multiple paths, use the Set File Search Path option of the File menu on the Xprofiler GUI. See “Setting the file search sequence” on page 270 for more information. To specify /lib/profiled/libc.a:shr.o as an alternative path name for your shared libraries, type: xprofiler -L /lib/profiled/libc.a:shr.o
-s Produce the gmon.sum profile data file (if multiple gmon.out files are specified when Xprofiler is started). The gmon.sum file represents the sum of the profile information in all the specified profile files. Note that if you specify a single gmon.out file, the gmon.sum file contains the same data as the gmon.out file. To write the sum of the data from three profile data files, gmon.out.1, gmon.out.2, and gmon.out.3, into a file called gmon.sum, type: xprofiler -s a.out gmon.out.1 gmon.out.2 gmon.out.3
-z Include functions that have both zero CPU usage and no call counts in the Flat Profile, Call Graph Profile, and Function Index reports. A function will not have a call count if the file that contains its definition was not compiled with the -pg flag, which is common with system library files. To include all functions used by the application that have zero CPU usage and no call counts in the Flat Profile, Call Graph Profile, and Function Index reports, type: xprofiler -z a.out gmon.out

After you enter the xprofiler command, the Xprofiler main window appears and displays your application's data.

Loading files from the Xprofiler GUI

If you enter the xprofiler command on its own, you can then specify an executable file, one or more profile data file, and any flags, from within the Xprofiler GUI. You use the Load File option of the File menu to do this.

If you enter the xprofiler -h or xprofiler -? command, Xprofiler displays the usage statement for the command and then exits.

When you enter the xprofiler command alone, the Xprofiler main window appears. Because you did not load an executable file or specify a profile data file, the window will be empty, as shown below.

From the Xprofiler GUI, select File, then Load File from the menu bar. The Load Files Dialog window will appear, as shown below. Figure 16. The Xprofiler main window.

The Load Files Dialog window lets you specify your application's executable file and its corresponding profile data (gmon.out) files. When you load a file, you can also specify the various command-line options that let you control the way Xprofiler displays the profiled data.

To load the files for the application you want to profile, you must specify the following:

  • the binary executable file Figure 17. The Load Files Dialog window

  • one or more profile data files

Optionally, you can also specify one or more command-line flags.

The binary executable file:

You can specify the binary executable file from the Binary Executable File: area of the Load Files Dialog window.

Use the scroll bars of the Directories and Files selection boxes to locate the executable file you want to load. By default, all of the files in the directory from which you called Xprofiler appear in the Files selection box.

To make locating your binary executable files easier, the Binary Executable File: area includes a Filter button. Filtering lets you limit the files that are displayed in the Files selection box to those of a specific directory or of a specific type. For information about filtering, see Filtering what you see. Figure 18. The Binary Executable File dialog

Profile data files:

You can specify one or more profile data files from the gmon.out Profile Data File(s) area of the Load Files Dialog window.

When you start Xprofiler using the xprofiler command, you are not required to indicate the name of the profile data file. If you do not specify a profile data file, Xprofiler searches your directory for the presence of a file named gmon.out and, if found, places it in the Selection field of the gmon.out Profile Data File(s) area, as the default. Xprofiler then uses this file as input, even if it is not related to the binary executable file you specify. Because this will cause Xprofiler to display incorrect data, it is important that you enter the correct file into this field. If the profile data file you want to use is named something other than what appears in the Selection field, you must replace it with the correct file name.

Use the scroll bars of the Directories and Files selection boxes to locate one or more of the profile data (gmon.out) files you want to specify. The file you use does not have to be named gmon.out, and you can specify more than one profile data file.

To make locating your output files easier, the gmon.out Profile Data File(s) area includes a Filter button. Filtering lets you limit the files that are displayed in the Files selection box to those in a specific directory or of a specific type. For information about filtering, see Filtering what you see. Figure 19. The gmon.out Profile Data File area

Specifying command line options (from the GUI):

Specify command line flags from the Command Line Options area of the Load Files Dialog window.

You can specify one or more flags as follows:

Table 7. Xprofiler GUI command-line flags

Use this flag: To: For example:
-a (field) Add alternative paths to search for source code and library files, or changes the current path search order. After clicking the OK button, any modifications to this field are also made to the Enter Alt File Search Paths: field of the Alt File Search Path Dialog window. If both the Load Files Dialog window and the Alt File Search Path Dialog window are opened at the same time, when you make path changes in the Alt File Search Path Dialog window and click OK, these changes are also made to the Load Files Dialog window. Also, when both of these windows are open at the same time, clicking the OK or Cancel buttons in the Load Files Dialog window causes both windows to close. If you want to restore the Alt File Search Path(s) (-a): field to the same state as when the Load Files Dialog window was opened, click the Reset button. You can use the “at” symbol (@) with this flag to represent the default file path, in order to specify that other paths be searched before the default path. To set an alternative file search path so that Xprofiler searches pathA, the default path, then pathB, type pathA:@:pathB in the Alt File Search Path(s) (-a) field.

-b (button) Suppress the printing of the field descriptions for the Flat Profile, Call Graph Profile, and Function Index reports when they are written to a file with the Save As option of the File menu. To suppress printing of the field descriptions for the Flat Profile, Call Graph Profile, and Function Index reports in the saved file, set the -b button to the pressed-in position. Figure 20. The Command Line Options area

Table 7. Xprofiler GUI command-line flags (continued)

Use this flag: To: For example:
-c (field) Load the specified configuration file. If the -c option was used on the command line, or a configuration file had been previously loaded with the Load Files Dialog window or the Load Configuration File Dialog window, the name of the most recently loaded file will appear in the Configuration File (-c): text field in the Load Files Dialog window, as well as the Selection field of Load Files Dialog window. If the Load Files Dialog window and the Load Files Dialog window are open at the same time, when you specify a configuration file in the Load Configuration File Dialog window and then click the OK button, the name of the specified file also appears in the Load Files Dialog window. Also, when both of these windows are open at the same time, clicking the OK or Cancel button in the Load Files Dialog window causes both windows to close. When entries are made to both the Configuration File (-c): and Initial Display (-disp_max): fields in the Load Files Dialog window, the value in the Initial Display (-disp_max): field is ignored, but is retained the next time this window is opened. If you want to retrieve the file name that was in the Configuration File (-c): field when the Load Files Dialog window was opened, click the Reset button. To load the configuration file myfile.cfg, type myfile.cfg in the Configuration File (-c) field.

-disp_max (field) Set the number of function boxes that Xprofiler initially displays in the function call tree. The value supplied with this flag can be any integer between 0 and 5000. Xprofiler displays the function boxes for the most CPU-intensive functions through the number you specify. For example, if you specify 50, Xprofiler displays the function boxes for the 50 functions in your program with the highest CPU usage. After this, you can change the number of function boxes that are displayed using the Filter menu options. This flag has no effect on the content of any of the Xprofiler reports. To display the function boxes for the 50 most CPU-intensive functions in the function call tree, type 50 in the Init Display (-disp_max) field.

-e (field) Deemphasize the general appearance of the function box for the specified function in the function call tree, and limits the number of entries for this function in the Call Graph Profile report. This also applies to the specified function's descendants, as long as they have not been called by non-specified functions.

In the function call tree, the function box for the specified function is made unavailable. The box size and the content of the label remain the same. This also applies to descendant functions, as long as they have not been called by non-specified functions.

In the Call Graph Profile report, an entry for a specified function only appears where it is a child of another function, or as a parent of a function that also has at least one non-specified function as its parent. The information for this entry remains unchanged. Entries for descendants of the specified function do not appear unless they have been called by at least one non-specified function in the program. To deemphasize the appearance of the function boxes for foo and bar and their qualifying descendants in the function call tree, and limit their entries in the Call Graph Profile report, type foo and bar in the Exclude Routines (-e) field.

Multiple functions are separated by a space.

Table 7. Xprofiler GUI command-line flags (continued)

Use this flag: To: For example:
-E (field) Change the general appearance and label information of the function box for the specified function in the function call tree. This flag also limits the number of entries for this function in the Call Graph Profile report, and changes the CPU data associated with them. These results also apply to the specified function's descendants, as long as they have not been called by non-specified functions in the program. In the function call tree, the function box for the specified function appears greyed out, and the box size and shape also changes so that it appears as a square of the smallest permitted size. In addition, the CPU time shown in the function box label, appears as 0. The same applies to function boxes for descendant functions, as long as they have not been called by non-specified functions. This flag also causes the CPU time spent by the specified function to be deducted from the CPU total on the left in the label of the function box for each of the specified function's ancestors. In the Call Graph Profile report, an entry for the specified function only appears where it is a child of another function, or as a parent of a function that also has at least one non-specified function as its parent. When this is the case, the time in the self and descendants columns for this entry is set to 0. In addition, the amount of time that was in the descendants column for the specified function is subtracted from the time listed under the descendants column for the profiled function. As a result, be aware that the value listed in the % time column for most profiled functions in this report will change. To change the display and label information for foo and bar and their qualifying descendants in the function call tree, and limit their entries and data in the Call Graph Profile report, type foo bar in the Exclude Routines (-E) field. Multiple functions are separated by a space.

-f (field) Deemphasize the general appearance of all function boxes in the function call tree, except for that of the specified function and its descendants. In addition, the number of entries in the Call Graph Profile report for the non-specified functions and non-descendant functions is limited. The -f flag overrides the -e flag.

In the function call tree, all function boxes except for that of the specified function and its descendants are made unavailable. The size of these boxes and the content of their labels remain the same. For the specified function and its descendants, the appearance of the function boxes and labels remain the same.

In the Call Graph Profile report, an entry for a non-specified or non-descendant function only appears where it is a parent or child of a specified function or one of its descendants. All information for this entry remains the same. To deemphasize the display of function boxes for all functions in the function call tree except for foo and bar and their descendants, and limit their types of entries in the Call Graph Profile report, type foo bar in the Include Routines (-f) field.

Multiple functions are separated by a space.

Table 7. Xprofiler GUI command-line flags (continued)

Use this flag: To: For example:
-F (field) Change the general appearance and label information of all function boxes in the function call tree except for that of the specified function and its descendants. In addition, the number of entries in the Call Graph Profile report for the non-specified and non-descendant functions is limited, and the CPU data associated with them is changed. The -F flag overrides the -E flag. In the function call tree, the function box for the specified function is made unavailable, and its size and shape also changes so that it appears as a square of the smallest permitted size. In addition, the CPU time shown in the function box label, appears as 0. In the Call Graph Profile report, an entry for a non-specified or non-descendant function only appears where it is a parent or child of a specified function or one of its descendants. When this is the case, the time in the self and descendants columns for this entry is set to 0. As a result, be aware that the value listed in the % time column for most profiled functions in this report will change. To change the display and label information of the function boxes for all functions except the functions foo and bar and their descendants, and limit their types of entries and data in the Call Graph Profile report, type foo bar in the Include Routines (-F) field. Multiple functions are separated by a space.

-L (field) Set the alternative path name for locating shared objects. If you plan to specify multiple paths, use the Set File Search Path option of the File menu on the Xprofiler GUI. See “Setting the file search sequence” for information. To specify /lib/profiled/libc.a:shr.o as an alternative path name for your shared libraries, type /lib/profiled/libc.a:shr.o in this field.

-s (button) Produces the gmon.sum profile data file, if multiple gmon.out files are specified when Xprofiler is started. The gmon.sum file represents the sum of the profile information in all the specified profile files. Note that if you specify a single gmon.out file, the gmon.sum file contains the same data as the gmon.out file. To write the sum of the data from three profile data files, gmon.out.1, gmon.out.2, and gmon.out.3, into a file called gmon.sum, set the -s button to the pressed-in position.

-z (button) Includes functions that have both zero CPU usage and no call counts in the Flat Profile, Call Graph Profile, and Function Index reports. A function will not have a call count if the file that contains its definition was not compiled with the -pg flag, which is common with system library files. To include all functions used by the application that have zero CPU usage and no call counts in the Flat Profile, Call Graph Profile, and Function Index reports, set the -z button to the pressed-in position.

After you have specified the binary executable file, one or more profile data files, and any command-line flags you want to use, click the OK button to save the changes and close the window. Xprofiler loads your application and displays its performance data.

Setting the file search sequence

You can specify where you want Xprofiler to look for your library files and source code files by using the Set File Search Paths option of the File menu.

By default, Xprofiler searches the default paths first and then any alternative paths you specify.

Default paths:

For library files, Xprofiler uses the paths recorded in the specified gmon.out files.

If you use the -L flag, the path you specify with it will be used instead of those in the gmon.out files.

Note: The -L flag enables only one path to be specified, and you can use this flag only once.

For source code files, the paths recorded in the specified a.out file are used.

Alternative paths:

You specify the alternative paths with the Set File Search Paths option of the File menu.

For library files, if everything else failed, the search will be extended to the path (or paths) specified by the LIBPATH environment variable associated with the executable file.

To specify alternative paths, do the following:

  1. Select the File menu, and then the Set File Search Paths option. The Alt File Search Path Dialog window appears.

  2. Enter the name of the path in the Enter Alt File Search Path(s) text field. You can specify more than one path by separating each path name with a colon (:) or a space.

Note

  1. You can use the “at” symbol (@) with this option to represent the default file path, in order to specify that other paths be searched before the default path. For example, to set the alternative file search paths so that Xprofiler searches pathA, the default path, then pathB, type pathA:@:pathB in the Alt File Search Path(s) (-a) field. b. If @ is used in the alternative search path, the two buttons in the Alt File Search Path Dialog window will be unavailable, and will have no effect on the search order.
  1. Click the OK button. The paths you specified in the text field become the alternative paths.

Changing the search sequence:

You can change the order of the search sequence for library files and source code files using the Set File Search Paths option of the File menu.

To change the search sequence, complete the following steps.

  1. Select the File menu, and then the Set File Search Paths option. The Alt File Search Path Dialog window appears.

  2. To indicate that the file search should use alternative paths first, click the Check alternative path(s) first button.

  3. Click OK. This changes the search sequence to the following: a. Alternative paths b. Default paths c. Paths specified in LIBPATH (library files only)

To return the search sequence back to its default order, repeat steps 1 through 3, but in step 2, click the Check default path(s) first button. When the action is confirmed (by clicking OK), the search sequence will start with the default paths again.

If a file is found in one of the alternative paths or a path in LIBPATH, this path now becomes the default path for this file throughout the current Xprofiler session (until you exit this Xprofiler session or load a new set of data).

Xprofiler 화면 이해하기

Xprofiler와 gprof 명령의 가장 큰 차이는 Xprofiler가 텍스트 데이터에 더해 응용 프로그램의 CPU 사용을 그림으로 보여 준다는 것입니다.

Xprofiler는 프로파일링한 프로그램을 주 창 하나에 보여 주며, 여러 종류의 그래픽으로 프로그램의 관련 부분을 나타냅니다. 함수는 녹색 상자(함수 상자, function box)로, 함수 사이의 호출은 파란 화살표(호출 호, call arc)로 나타냅니다. 응용 프로그램의 각 라이브러리에 속한 함수 상자와 호출 호는 클러스터 상자(cluster box)라는 울타리 안에 나타납니다.

Xprofiler 주 창

Xprofiler 주 창은 응용 프로그램 안의 함수와 호출, 그 사이의 관계를 그림으로 보여 줍니다. 온라인 도움말을 포함해 메뉴가 여섯 개 있습니다. 주 창에는 함수 호출 트리가 나오며, 함수 호출 트리는 응용 프로그램 안의 함수를 나타내는 함수 상자, 호출 호, 클러스터 상자를 보여 줍니다.

참고: Xprofiler를 처음 열면 기본으로 함수 상자가 라이브러리별로 묶여(clustered) 있습니다. 라이브러리마다 클러스터 상자가 둘러싸고 그 안의 함수 상자와 호는 작게 그려집니다. 자세히 보려면 묶음을 풀어야 합니다(원문은 File 메뉴라고 했지만 Uncluster Functions는 Filter 메뉴에 있습니다).

Xprofiler의 주 메뉴:

메뉴 하는 일
File Xprofiler가 쓸 실행 파일(a.out)과 프로파일 데이터 파일(gmon.out)을 지정하고, 파일에 접근하고 저장하는 방식을 제어합니다.
View 함수 호출 트리의 특정 부분에 초점을 맞춰 응용 프로그램의 중요한 부분을 더 잘 보게 합니다.
Filter 함수 호출 트리의 특정 부분을 더하고, 빼고, 바꿉니다. 보이는 것을 제어해 가장 중요한 대상에 집중할 수 있습니다.
Report 프로파일링 데이터를 텍스트와 표 형식으로 여러 가지 보여 줍니다. 텍스트 데이터 보기, 파일로 저장하기, 해당 소스 코드 보기, 함수 호출 트리에서 해당 함수 상자나 호출 호 찾기도 할 수 있습니다.
Utility Locate Function By Name 한 가지가 있으며, 함수 호출 트리에서 특정 함수를 강조 표시합니다.

Xprofiler의 숨은 메뉴:

메뉴 하는 일과 여는 법
Function 함수 호출 트리의 함수에 여러 작업을 합니다. 통계 데이터 보기, 소스 코드 보기, 보이는 함수 제어 등입니다. 창에 보이지 않으며, 관심 있는 함수 상자를 오른쪽 클릭하면 열리고 그 함수가 선택됩니다. 이후 Function 메뉴의 동작은 그 함수에 적용됩니다.
Arc 호출 호의 호출자(caller)와 피호출자(callee) 함수를 찾습니다. 관심 있는 호출 호를 오른쪽 클릭하면 열리고 그 호가 선택됩니다.
Cluster Node Xprofiler가 라이브러리를 보여 주는 방식을 제어합니다. 먼저 함수 상자가 라이브러리별로 묶여 있어야 합니다("라이브러리 묶기" 참고). 클러스터 상자의 가장자리를 오른쪽 클릭하면 열리고 그 클러스터가 선택되며, 동작은 그 라이브러리 클러스터 안의 함수에 적용됩니다.

표시 상태 필드(display status field):

Xprofiler 창 맨 아래에 있으며 다음 정보를 보여 줍니다.

  • 응용 프로그램 이름
  • 이 세션에서 쓴 gmon.out 파일 수
  • 응용 프로그램이 쓴 전체 CPU 양
  • 응용 프로그램의 함수와 호출 수, 그 가운데 지금 보이는 수

함수를 나타내는 방식:

함수는 함수 호출 트리에서 녹색 상자로 나타납니다. 상자의 크기와 모양이 CPU 사용량을 나타냅니다. 상자의 높이는 그 함수 자체를 실행하는 데 쓴 CPU 시간, 너비는 그 함수 자체와 자손 함수를 실행하는 데 쓴 CPU 시간입니다.

이런 표현을 요약 모드(summary mode)라고 합니다. 요약 모드에서 상자의 크기와 모양은 여러 gmon.out 파일에서 그 함수 자체에 쓴 CPU 시간의 합과, 그 함수와 자손 함수가 쓴 시간의 합으로 정해집니다. 넓고 납작한 상자는 자기 자신에는 CPU를 비교적 적게 쓰는(대부분의 시간을 자손에서 쓰는) 함수입니다. 대부분의 시간을 자기 자신만 실행하는 데 쓰는 함수의 상자는 대략 정사각형입니다.

평균 모드(average mode)로도 나타낼 수 있습니다. 평균 모드에서 상자의 크기와 모양은 적재한 모든 gmon.out 파일에서 그 함수 자체에 쓴 CPU 시간의 평균과 표준 편차로 정해집니다. 높이는 평균 CPU 시간, 너비는 CPU 시간의 표준 편차입니다. 평균 모드는 gmon.out 파일을 둘 이상 줄 때만 쓸 수 있습니다("함수 호출 트리의 표현 방식 제어하기" 참고).

함수 호출 트리의 각 함수 상자 아래에는 함수 이름과 관련 CPU 사용 데이터를 담은 이름표가 있습니다. 이름표는 "기본 데이터 얻기"(Xprofiler (2))를 봅니다. 원문 그림은 sub1과 printf 두 함수의 상자가 화면에 나타나는 모습입니다.

함수 상자마다 메뉴가 있어, 상자에 마우스를 올리고 오른쪽 단추를 누르면 열립니다. 기본 성능 수치를 빨리 볼 수 있는 정보 상자도 있어, 왼쪽 단추를 누르면 열립니다.

함수 사이의 호출을 나타내는 방식:

함수 사이 호출은 해당 함수 상자 사이에 이어진 파란 실선 화살표, 곧 호출 호로 나타냅니다. 화살촉은 호출 방향을 나타내며, 화살촉이 가리키는 상자의 함수가 호출을 받습니다. 호출하는 함수를 호출자(caller), 호출을 받는 함수를 피호출자(callee)라고 합니다.

호출 호마다 두 함수 사이에 오간 호출 수를 나타내는 숫자 이름표가 있습니다. 호출 호마다 호출자와 피호출자 함수 상자를 찾는 메뉴(오른쪽 클릭)와, 호출자가 피호출자를 부른 횟수를 보여 주는 정보 상자(왼쪽 클릭)가 있습니다.

라이브러리 클러스터를 나타내는 방식:

Xprofiler는 각 공유 라이브러리에 속한 함수 상자와 호출 호를 클러스터 상자로 모을 수 있습니다. 라이브러리마다 상자가 둘러싸므로 개별 함수 상자와 호출 호는 잘 보이지 않습니다. 자세히 보려면 Filter 메뉴의 Uncluster Functions로 묶음을 풉니다.

클러스터 상자 안의 함수 상자 크기는 같은 라이브러리 클러스터 안의 다른 함수와 비교한 상대 크기입니다. 반면 모든 라이브러리의 묶음을 풀면 각 함수 상자의 크기는 응용 프로그램의 모든 함수와 비교한 상대 크기입니다.

라이브러리 클러스터마다 클러스터 상자를 다루는 메뉴(가장자리에서 오른쪽 클릭)와, 라이브러리 이름과 그 안의 함수가 쓴 전체 CPU 사용량(초)을 보여 주는 정보 상자(가장자리에서 왼쪽 클릭)가 있습니다.

영어 원문

Understanding the Xprofiler display

The primary difference between Xprofiler and the gprof command is that Xprofiler gives you a graphical picture of your application's CPU consumption in addition to textual data.

Xprofiler displays your profiled program in a single main window. It uses several types of graphical images to represent the relevant parts of your program. Functions appear as solid green boxes (called

function boxes), and the calls between them appear as blue arrows (called call arcs). The function boxes and call arcs that belong to each library within your application appear within a fenced-in area called a cluster box.

Xprofiler main window

The Xprofiler main window contains a graphical representation of the functions and calls within your application, as well as their interrelationships. The window provides six menus, including one for online help.

When an application has been loaded, the Xprofiler main window looks similar to the following:

In the main window, Xprofiler displays the function call tree. The function call tree displays the function boxes, call arcs, and cluster boxes that represent the functions within your application. Figure 21. The Xprofiler main window with application loaded

Note: When Xprofiler first opens, by default, the function boxes for your application will be clustered by library. A cluster box appears around each library, and the function boxes and arcs within the cluster box are reduced in size. To see more detail, you must uncluster the functions. To do this, select the File menu and then the Uncluster Functions option.

Xprofiler's main menus:

The following are part of Xprofiler's main menu.

The file menu:

The File menu lets you specify the executable (a.out) files and profile data (gmon.out) files that Xprofiler will use. It also lets you control how your files are accessed and saved.

The view menu:

The View menu lets you focus on specific portions of the function call tree in order to get a better view of the application's critical areas.

The filter menu:

The Filter menu lets you add, remove, and change specific parts of the function call tree. By controlling what Xprofiler displays, you can focus on the objects that are most important to you.

The report menu:

The report menu provides several types of profiled data in a textual and tabular format.

In addition to presenting the profiled data, the options of the Report menu let you do the following:

  • Display textual data

  • Save it to a file

  • View the corresponding source code

  • Locate the corresponding function box or call arc in the function call tree

The utility menu:

The Utility menu contains one option, Locate Function By Name, which lets you highlight a particular function in the function call tree.

Xprofiler's hidden menus:

The function menu:

The Function menu lets you perform a number of operations for any of the functions shown in the function call tree.

You can access statistical data, look at source code, and control which functions are displayed.

The Function menu is not visible from the Xprofiler window. You access it by right-clicking on the function box of the function in which you are interested. By doing this, you open the Function menu, and select this function as well. Then, when you select actions from the Function menu, the actions are applied to this function.

The arc menu:

The Arc menu lets you locate the caller and callee functions for a particular call arc. A call arc is the representation of a call between two functions within the function call tree.

The Arc menu is not visible from the Xprofiler window. You access it by right-clicking on the call arc in which you are interested. By doing this, you open the Arc menu, and select that call arc as well. Then, when you perform actions with the Arc menu, they are applied to that call arc.

The cluster node menu:

The cluster node menu lets you control the way your libraries are displayed by Xprofiler.

To access the Cluster Node menu, the function boxes in the function call tree must first be clustered by library. For information about clustering and unclustering the function boxes of your application, see Clustering libraries. When the function call tree is clustered, all the function boxes within each library appear within a cluster box.

The Cluster Node menu is not visible from the Xprofiler window. You access it by right-clicking on the edge of the cluster box in which you are interested. By doing this, you open the Cluster Node menu, and select that cluster as well. Then, when you perform actions with the Cluster Node menu, they are applied to the functions within that library cluster.

The display status field:

The display status filed is at the bottom of the Xprofiler window.

The display status field provides the following information:

  • Name of your application

  • Number of gmon.out files used in this session

  • Total amount of CPU used by the application

  • Number of functions and calls in your application, and how many of these are currently displayed

How functions are represented:

Functions are represented by solid green boxes in the function call tree.

The size and shape of each function box indicates its CPU usage. The height of each function box represents the amount of CPU time it spent on executing itself. The width of each function box represents the amount of CPU time it spent executing itself, plus its descendant functions.

This type of representation is known as summary mode. In summary mode, the size and shape of each function box is determined by the total CPU time of multiple gmon.out files used on that function alone, and the total time used by the function and its descendant functions. A function box that is wide and flat represents a function that uses a relatively small amount of CPU on itself (it spends most of its time on its descendants). The function box for a function that spends most of its time executing only itself will be roughly square-shaped.

Functions can also be represented in average mode. In average mode, the size and shape of each function box is determined by the average CPU time used on that function alone, among all loaded gmon.out files, and the standard deviation of CPU time for that function among all loaded gmon.out files. The height of each function node represents the average CPU time, among all the input gmon.out files, used on the function itself. The width of each node represents the standard deviation of CPU time, among the gmon.out files, used on the function itself. The average mode representation is available only when more

than one gmon.out file is entered. For more information about summary mode and average mode, see Controlling the representation of the function call tree.

Under each function box in the function call tree is a label that contains the name of the function and related CPU usage data. For information about the function box labels, see Obtaining basic data.

The following figure shows the function boxes for two functions, sub1 and printf, as they would appear in the Xprofiler display.

Each function box has its own menu. To access it, place your mouse cursor over the function box of the function you are interested in and press the right mouse button. Each function also has an information box that lets you get basic performance numbers quickly. To access the information box, place your mouse cursor over the function box of the function you are interested in and press the left mouse button.

How calls between functions are depicted:

The calls made between each of the functions in the function call tree are represented by blue arrows extending between their corresponding function boxes. Figure 22. Function boxes and arcs in the Xprofiler display

These lines are called call arcs. Each call arc appears as a solid blue line between two functions. The arrowhead indicates the direction of the call; the function represented by the function box it points to is the one that receives the call. The function making the call is known as the caller, while the function receiving the call is known as the callee.

Each call arc includes a numeric label that indicates how many calls were exchanged between the two corresponding functions.

Each call arc has its own menu that lets you locate the function boxes for its caller and callee functions. To access it, place your mouse cursor over the call arc for the call in which you are interested, and press the right mouse button. Each call arc also has an information box that shows you the number of times the caller function called the callee function. To access the information box, place your mouse cursor over the call arc for the call in which you are interested, and press the left mouse button.

How library clusters are represented:

Xprofiler lets you collect the function boxes and call arcs that belong to each of your shared libraries into cluster boxes.

Because there will be a box around each library, the individual function boxes and call arcs will be difficult to see. If you want to see more detail, you must uncluster the function boxes. To do this, select the Filter menu and then the Uncluster Functions option.

When viewing function boxes within a cluster box, note that the size of each function box is relative to those of the other functions within the same library cluster. On the other hand, when all the libraries are unclustered, the size of each function box is relative to all the functions in the application (as shown in the function call tree).

Each library cluster has its own menu that lets you manipulate the cluster box. To access it, place your mouse cursor over the edge of the cluster box you are interested in, and press the right mouse button. Each cluster also has an information box that shows you the name of the library and the total CPU usage (in seconds) consumed by the functions within it. To access the information box, place your mouse cursor over the edge of the cluster box you are interested in and press the left mouse button.

화면 갱신 방식 제어하기

Overview 창의 Utility 메뉴에서 화면 갱신 방식을 고를 수 있습니다.

기본은 Immediate Update로, 강조 영역을 움직이는 동안 그 안의 항목을 바로바로 보여 줍니다. Delayed Update는 강조 영역을 원하는 곳으로 옮기고 마우스 단추를 놓았을 때만 화면을 갱신합니다. Immediate Update는 강조 영역을 움직일 때 보이는 것에만 적용되며, 강조 영역 안 항목의 크기 조정은 늘 지연되어 이루어집니다.

영어 원문

Controlling how the display is updated

The Utility menu of the Overview Window lets you choose the mode in which the display is updated.

The default is the Immediate Update option, which causes the display to show you the items in the highlight area as you are moving it around. The Delayed Update option, on the other hand, causes the display to be updated only when you have moved the highlight area over the area in which you are interested, and released the mouse button. The Immediate Update option applies only to what you see when you move the highlight area; it has no effect on the resizing of items in highlight area, which is always delayed.

그 밖의 보기 옵션

Xprofiler에서 함수 호출 트리를 보여 주는 방식을 취향에 따라 바꿀 수 있습니다.

함수 호출 트리의 그래픽 스타일 제어하기

함수 상자를 2차원이나 3차원으로 고를 수 있습니다. 기본은 2차원이며, 3차원으로 바꾸려면 View 메뉴에서 3-D Image를 고릅니다.

함수 호출 트리의 방향 제어하기

함수 호출 트리를 위에서 아래로, 또는 왼쪽에서 오른쪽으로 보여 줄 수 있습니다. 기본은 위에서 아래이며, 왼쪽에서 오른쪽으로 보려면 View 메뉴에서 Layout: Left→Right를 고릅니다.

함수 호출 트리의 표현 방식 제어하기

함수 호출 트리를 요약 모드나 평균 모드로 나타낼 수 있습니다.

View 메뉴의 Summary Mode를 고르면 각 함수 상자의 크기와 모양은 여러 gmon.out 파일에서 그 함수 자체에 쓴 CPU 시간의 합과, 그 함수와 자손 함수가 쓴 시간의 합으로 정해집니다. 높이는 함수 자체에 쓴 전체 CPU 시간, 너비는 함수와 자손 함수에 쓴 전체 CPU 시간입니다. 요약 모드에서는 Summary Mode 항목이 비활성이고 Average Mode 항목이 활성입니다.

View 메뉴의 Average Mode를 고르면 각 함수 상자의 크기와 모양은 적재한 모든 gmon.out 파일에서 그 함수 자체에 쓴 CPU 시간의 평균과 표준 편차로 정해집니다. 높이는 평균 CPU 시간, 너비는 CPU 시간의 표준 편차입니다.

평균 모드의 목적은 응용 프로그램에 gmon.out 파일이 여럿 있을 때 작업 부하 분산(load balancing) 문제를 드러내는 것입니다. 대체로 표준 편차가 큰 함수 노드는 넓고, 작은 노드는 가늡니다.

요약 모드와 평균 모드는 함수 호출 트리의 모양과 이름표에만 영향을 줍니다. Xprofiler 보고서와 코드 화면의 성능 데이터는 늘 요약 데이터입니다. gmon.out 파일을 하나만 지정하면 Summary Mode와 Average Mode가 비활성이며 늘 요약 모드로 보여 줍니다.

영어 원문

Other viewing options

Xprofiler lets you change the way it displays the function call tree, based on your personal preferences.

Controlling the graphic style of the function call tree

You can choose between two-dimensional and three-dimensional function boxes in the function call tree.

The default style is two-dimensional. To change to three-dimensional, select the View menu, and then the 3-D Image option. The function boxes in the function call tree now appear in three-dimensional format.

Controlling the orientation of the function call tree

You can choose to have Xprofiler display the function call tree in either top-to-bottom or left-to-right format.

The default is top-to-bottom. To see the function call tree displayed in left-to-right format, select the View menu, and then the Layout: Left→Right option. The function call tree now displays in left-to-right format, as shown below.

Controlling the representation of the function call tree

You can choose to have Xprofiler represent the function call tree in either summary mode or average mode.

When you select the Summary Mode option of the View menu, the size and shape of each function box is determined by the total CPU time of multiple gmon.out files used on that function alone, and the total time used by the function and its descendant functions. The height of each function node represents the total CPU time used on the function itself. The width of each node represents the total CPU time used on Figure 23. Left-to-right format

the function and its descendant functions. When the display is in summary mode, the Summary Mode option is unavailable and the Average Mode option is activated.

When you select the Average Mode option of the View menu, the size and shape of each function box is determined by the average CPU time used on that function alone, among all loaded gmon.out files, and the standard deviation of CPU time for that function among all loaded gmon.out files. The height of each function node represents the average CPU time, among all the input gmon.out files, used on the function itself. The width of each node represents the standard deviation of CPU time, among the gmon.out files, used on the function itself.

The purpose of average mode is to reveal workload balancing problems when an application is involved with multiple gmon.out files. In general, a function node with large standard deviation has a wide width, and a node with small standard deviation has a slim width.

Both summary mode and average mode affect only the appearance of the function call tree and the labels associated with it. All the performance data in Xprofiler reports and code displays are always summary data. If only one gmon.out file is specified, Summary Mode and Average Mode will be unavailable, and the display is always in Summary Mode.

보이는 것 거르기

Xprofiler를 처음 열면 주 창에 함수 호출 트리 전체가 나옵니다. 실행 파일과 그것이 쓰는 공유 라이브러리의 함수 상자와 호출 호가 모두 들어 있습니다. 주 창에 보이는 것을 여러 방법으로 단순하게 만들 수 있습니다.

참고: Filter 메뉴의 거르기 옵션은 함수 호출 트리의 모양만 바꿉니다. Report 메뉴의 보고서에 든 성능 데이터에는 영향이 없습니다.

함수 호출 트리의 상태 되돌리기

Xprofiler에서는 함수 호출 트리에 노드와 호를 더하거나 빼는 작업을 되돌릴 수 있습니다. 되돌리면 함수 상자나 호출 호를 더하거나 뺀 작업의 효과가 취소되어, 그 작업 직전의 모습으로 돌아갑니다. 되돌리려면 Filter 메뉴에서 Undo를 고릅니다.

Undo를 쓰면 함수 호출 트리의 확대 초점이 사라지고 주 화면에 트리 전체가 보이도록 완전히 축소됩니다. Xprofiler를 시작했을 때는 Undo가 비활성이며, 함수 호출 트리에 더하기나 빼기 작업이 있은 뒤에만 활성이 됩니다. 되돌린 뒤에는 다음 더하기·빼기 작업까지 다시 비활성입니다.

Undo를 활성으로 만드는 항목은 다음과 같습니다.

  • 주 File 메뉴: Load Configuration
  • 주 Filter 메뉴: Show Entire Call Tree, Hide All Library Calls, Add Library Calls, Filter by Function Names, Filter by CPU Time, Filter by Call Counts
  • Function 메뉴: Immediate Parents, All Paths To, Immediate Children, All Paths From, All Functions on The Cycle, Show This Function Only, Hide This Function, Hide Descendant Functions, Hide This & Descendant Functions

Load Configuration Dialog나 Filter by CPU Time Dialog 같은 대화상자를 열었다가 바로 취소하면 Undo의 상태는 바뀌지 않습니다. 일단 활성이 되면 Undo를 쓰거나 Load Files Dialog 창으로 새 파일을 적재할 때까지 활성으로 남습니다.

함수 호출 트리 전체 보기

Xprofiler를 처음 열면 기본으로 실행 파일과 공유 라이브러리의 모든 함수 상자와 호출 호가 주 창에 나옵니다. 그 뒤 특정 항목을 걸러 낼 수 있지만, 응용 프로그램을 다시 적재하지 않고 트리 전체를 다시 보고 싶을 때가 있습니다. Filter 메뉴에서 Show Entire Call Tree를 고르면 주 창의 내용을 지우고 함수 호출 트리 전체로 바꿉니다.

특정 객체 빼기와 넣기

주 창에 나오는 항목을 여러 방법으로 제어할 수 있습니다. 가장 관심 있는 것에 쉽게 집중하도록 특정 객체를 넣거나 뺍니다.

공유 라이브러리 함수 거르기:

대부분의 응용 프로그램은 공유 라이브러리 안의 함수를 부릅니다. 기본으로 이런 공유 라이브러리가 실행 파일과 함께 창에 나오므로 창이 붐벼 꼭 봐야 할 항목이 가려질 수 있습니다. 그럴 때 Filter 메뉴에서 Remove All Library Calls를 고르면 공유 라이브러리 함수 상자가 사라지고 실행 파일의 함수 상자만 남습니다.

라이브러리 호출을 다시 보이게 하려면 File 메뉴(원문 그대로)에서 Add Library Calls를 고릅니다. 함수 상자가 다시 나타나지만, 처음 트리에 있던 공유 라이브러리 호출이 모두 돌아오지는 않을 수 있습니다. Add Library Calls는 지금 창에 보이는 함수가 부른 라이브러리 함수의 상자만 다시 더하기 때문입니다.

특정 함수 상자만 다시 더하려면 다음과 같이 합니다.

  1. Filter 메뉴에서 Filter by Function Names를 고릅니다. Filter By Function Names 대화상자가 나옵니다.
  2. add these functions to graph 단추를 누르고 Enter function name 필드에 더할 함수 이름을 입력합니다. 이름이 여럿이면 공백으로 구분합니다. 입력한 문자열을 이름에 포함한 함수가 여럿이면 모두에 적용됩니다. 예를 들어 sub와 print를 지정했는데 프로그램에 sub1, psub1, printf라는 함수도 있으면 sub, sub1, psub1, print, printf가 모두 그래프에 더해집니다.
  3. OK를 누릅니다. 하나 이상의 함수 상자가 함수 호출 트리와 함께 나타납니다.

함수 특성으로 거르기:

Filter 메뉴에는 특정 특성에 따라 주 창에 함수 상자를 더하거나 빼는 다음 항목이 있습니다. 항목마다 다른 창에서 기준을 지정합니다.

  • Filter by Function Names
  • Filter by CPU Time
  • Filter by Call Counts

함수 이름으로 거르려면 다음과 같이 합니다.

  1. Filter 메뉴에서 Filter by Function Names를 고릅니다. Filter By Function Names 대화상자에는 add these functions to graph, remove these functions from the graph, display only these functions 항목이 있습니다.
  2. 항목을 고르고 Enter function name 필드에 적용할 함수 이름을 입력합니다. 예를 들어 printf 함수의 상자를 주 창에서 빼려면 remove this function from the graph 단추를 누르고 필드에 printf를 입력합니다. 이름은 여럿 입력할 수 있으며, 입력한 문자열을 이름에 포함한 함수가 여럿이면 모두에 적용됩니다(위 sub·print 예와 같음).
  3. OK를 누릅니다. 함수 호출 트리에 지정한 거르기가 반영됩니다.

CPU 시간으로 거르려면 다음과 같이 합니다.

  1. Filter 메뉴에서 Filter by CPU Time을 고릅니다. Filter By CPU Time 대화상자에는 show functions consuming the most CPU time과 show functions consuming the least CPU time 항목이 있습니다.
  2. 원하는 항목을 고릅니다(기본은 show functions consuming the most CPU time).
  3. 적용할 함수 수를 고릅니다(기본 1). Functions 막대의 슬라이더를 원하는 수까지 옮기거나 Slider Value 필드에 수를 입력합니다. 슬라이더와 필드는 서로 연동되며, 필드에 입력한 값은 Apply나 OK를 누를 때 슬라이더에 반영됩니다. 예를 들어 CPU를 가장 많이 쓴 함수 10개의 상자를 보려면 show functions consuming the most CPU를 고르고 10을 지정합니다.
  4. Apply를 누르면 대화상자를 닫지 않고 트리에 변경을 보여 주고, OK를 누르면 변경을 보여 주고 대화상자를 닫습니다.

호출 횟수로 거르려면 다음과 같이 합니다.

  1. Filter 메뉴에서 Filter by Call Counts를 고릅니다. Filter By Call Counts 대화상자에는 show arcs with the most call counts와 show arcs with the least call counts 항목이 있습니다.
  2. 원하는 항목을 고릅니다(기본은 show arcs with the most call counts).
  3. 적용할 호출 호 수를 고릅니다(기본 1). 필드에 입력한 값은 Apply나 OK를 누를 때 슬라이더에 반영됩니다. 예를 들어 호출 수가 가장 적은 호출 호 10개를 보려면 show arcs with the least call counts를 고르고 10을 지정합니다.
  4. Apply를 누르면 대화상자를 닫지 않고 변경을 보여 주고, OK를 누르면 변경을 보여 주고 대화상자를 닫습니다.

부모·자식 함수 넣고 빼기:

CPU를 적게 쓰는 함수를 분석하기에 앞서, CPU를 많이 쓰는 함수의 부모·자식 관계가 어떻게 동작하는지 이해하고 성능을 개선할 수 있어야 합니다.

응용 프로그램 성능을 튜닝할 때는 어느 함수가 CPU 시간을 가장 많이 썼는지 알고, 그 동작을 이해하려고 다음을 물어야 합니다.

  • 각 함수는 CPU 시간을 주로 어디에서 썼는가?
  • 이 함수를 부른 다른 함수는 무엇인가? 직접 불렀는가, 간접으로 불렀는가?
  • 이 함수가 부른 다른 함수는 무엇인가? 직접 불렀는가, 간접으로 불렀는가?

응용 프로그램이 크면 함수 호출 트리도 커서 CPU를 가장 많이 쓰는 함수를 찾기 어려울 수 있습니다. 이럴 때 Filter 메뉴의 Filter by CPU로 CPU 시간을 가장 많이 쓰는 함수의 상자만 보여 줍니다. 그다음 각 함수의 Function 메뉴로 부모와 자손 함수 상자를 트리에 더합니다. 이렇게 하면 응용 프로그램에서 CPU를 가장 많이 쓰는 부분의 함수 상자만 담은 작고 단순한 트리를 만들 수 있습니다.

자식 함수는 관심 있는 함수가 직접 부르는 함수입니다. 관심 있는 함수와 그 자식 함수의 상자만 보려면 다음과 같이 합니다.

  1. 관심 있는 함수 상자에 마우스를 올리고 오른쪽 단추를 누릅니다. Function 메뉴가 나옵니다.
  2. Function 메뉴에서 Immediate Children, Show Child Functions Only를 고릅니다. 현재 화면을 지우고 고른 함수와 그 자식 함수의 상자만 보여 줍니다.

부모 함수는 관심 있는 함수를 직접 부르는 함수입니다. 관심 있는 함수와 그 부모 함수의 상자만 보려면 다음과 같이 합니다.

  1. 관심 있는 함수 상자에 마우스를 올리고 오른쪽 단추를 누릅니다.
  2. Function 메뉴에서 Immediate Parents, Show Parent Functions Only를 고릅니다. 현재 화면을 지우고 고른 함수와 그 부모 함수의 상자만 보여 줍니다.

함수 호출 트리의 나머지는 지우지 않고 관심 있는 함수의 부모와 자식 함수 상자를 함께 보고 싶을 수 있습니다. 특히 Filter by CPU로 CPU를 가장 많이 쓰는 함수 둘 이상의 상자를 보여 주고 있을 때(둘 이상의 함수가 CPU를 너무 많이 쓴다고 의심할 때) 그렇습니다. 다음과 같이 합니다.

  1. 관심 있는 함수 상자에 마우스를 올리고 오른쪽 단추를 누릅니다.
  2. Function 메뉴에서 Immediate Parents, Add Parent Functions to Tree를 고릅니다. 현재 화면은 그대로 두고 부모 함수 상자를 더합니다.
  3. 같은 함수 상자에서 다시 오른쪽 단추를 누릅니다.
  4. Function 메뉴에서 Immediate Children, Add Child Functions to Tree를 고릅니다. 현재 화면은 그대로 두고 부모에 더해 자식 함수 상자도 더합니다.
영어 원문

Filtering what you see

When Xprofiler first opens, the entire function call tree appears in the main window.

This includes the function boxes and call arcs that belong to your executable file as well as the shared libraries that it uses. You can simplify what you see in the main window, and there are several ways to do this.

Note: Filtering options of the Filter menu let you change the appearance only of the function call tree. The performance data contained in the reports (through the Reports menu) is not affected.

Restoring the status of the function call tree

Xprofiler enables you to undo operations that involve adding or removing nodes and arcs from the function call tree.

When you undo an operation, you reverse the effect of any operation which adds or removes function boxes or call arcs to the function call tree. When you select the Undo option, the function call tree is returned to its appearance just prior to the performance of the add or remove operation. To undo an operation, select the Filter menu, and then the Undo option. The function call tree is returned to its appearance just prior to the performance of the add or remove operation.

Whenever you invoke the Undo option, the function call tree loses its zoom focus and zooms all the way out to reveal the entire function call tree in the main display. When you start Xprofiler, the Undo option is unavailable. It is activated only after an add or remove operation involving the function call tree takes place. After you undo an operation, the option is made unavailable again until the next add or remove operation takes place.

The options that activate the Undo option include the following:

  • In the main File menu: – Load Configuration

  • In the main Filter menu: – Show Entire Call Tree – Hide All Library Calls – Add Library Calls – Filter by Function Names – Filter by CPU Time – Filter by Call Counts

  • In the Function menu: – Immediate Parents – All Paths To – Immediate Children – All Paths From – All Functions on The Cycle – Show This Function Only – Hide This Function – Hide Descendant Functions – Hide This & Descendant Functions

If a dialog such as the Load Configuration Dialog or the Filter by CPU Time Dialog is invoked and then canceled immediately, the status of the Undo option is not affected. After the option is available, it stays that way until you invoke it, or a new set of files is loaded into Xprofiler through the Load Files Dialog window.

Displaying the entire function call tree

When you first open Xprofiler, by default, all the function boxes and call arcs of your executable and its shared libraries appear in the main window.

After that, you can choose to filter out specific items from the window. However, there might be times when you want to see the entire function call tree again, without having to reload your application. To do this, select the Filter menu, and then the Show Entire Call Tree option. Xprofiler erases whatever is currently displayed in the main window and replaces it with the entire function call tree.

Excluding and including specific objects

There are a number of ways that Xprofiler lets you control the items that display in the main window. You will want to include or exclude certain objects so that you can more easily focus on the things that are of most interest to you.

Filtering shared library functions:

In most cases, your application will call functions that are within shared libraries.

By default, these shared libraries display in the Xprofiler window along with your executable file. As a result, the window can get crowded and obscure the items that you most need to see. If this is the case, you can filter the shared libraries from the display. To do this, select the Filter menu, and then the Remove All Library Calls option.

The shared library function boxes disappear from the function call tree, leaving only the function boxes of your executable file visible.

If you removed the library calls from the display, you might want to restore them. To do this, select the File menu and then the Add Library Calls option.

The function boxes again appear with the function call tree. Note, however, that all of the shared library calls that were in the initial function call tree might not be added back. This is because the Add Library Calls option only adds back in the function boxes for the library functions that were called by functions that are currently displayed in the Xprofiler window.

To add only specific function boxes back into the display, do the following:

  1. Select the Filter menu, and then the Filter by Function Names option. The Filter By Function Names dialog window appears.

  2. From the Filter By Function Names Dialog window, click the add these functions to graph button, and then type the name of the function you want to add in the Enter function name field. If you enter more than one function name, you must separate them with a blank space between each function name string. If there are multiple functions in your program that include the string you enter in their names, the filter applies to each one. For example, if you specified sub and print, and your program also included functions named sub1, psub1, and printf. The sub, sub1, psub1, print, and printf functions would all be added to the graph.

  3. Click OK. One or more function boxes appears in the Xprofiler display with the function call tree.

Filtering by function characteristics:

Review the following steps to filter functions based on specific characteristics.

The Filter menu of Xprofiler offers the following options that enable you to add or subtract function boxes from the main window, based on specific characteristics:

  • Filter by Function Names

  • Filter by CPU Time

  • Filter by Call Counts

Each option uses a different window to let you specify the criteria by which you want to include or exclude function boxes from the window.

To filter by function names, do the following:

  1. Select the Filter menu and then the Filter by Function Names option. The following Filter By Function Names Dialog window appears:

The Filter By Function Names Dialog window includes the following options:

  • add these functions to graph

  • remove these functions from the graph

  • display only these functions

  1. From the Filter By Function Names Dialog window, select the option, and then type the name of the function (or functions) to which you want it applied in the Enter function name field. For example, if Figure 24. The Filter By Function Names Dialog window

you want to remove the function box for a function called printf from the main window, click the remove this function from the graph button, and type printf in the Enter function name field. You can enter more than one function name in this field. If there are multiple functions in your program that include the string you enter in their names, the filter will apply to each one. For example, if you specified sub and print, and your program also included functions named sub1, psub1, and printf, the option you chose would be applied to the sub, sub1, psub1, print, and printf functions.

  1. Click OK. The contents of the function call tree now reflect the filtering options you specified.

To filter by CPU time, do the following:

  1. Select the Filter menu and then the Filter by CPU Time option. The following Filter By CPU Time Dialog window appears: The Filter By CPU Time Dialog window includes the following options:
  • show functions consuming the most CPU time

  • show functions consuming the least CPU time

  1. Select the option you want (show functions consuming the most CPU time is the default).

  2. Select the number of functions to which you want it applied (1 is the default). You can move the slider in the Functions bar until the desired number appears, or you can enter the number in the Slider Value field. The slider and Slider Value field are synchronized so when the slider is updated, the text field value is updated also. If you enter a value in the text field, the slider is updated to that value when you click Apply or OK. For example, to display the function boxes for the 10 functions in your application that consumed the most CPU, you would select the show functions consuming the most CPU button, and specify 10 with the slider or enter the value 10 in the text field.

  3. Click Apply to show the changes to the function call tree without closing the dialog. Click OK to show the changes and close the dialog.

To filter by call counts, do the following:

  1. Select the Filter menu and then the Filter by Call Counts option. The Filter By Call Counts Dialog window appears. Figure 25. The Filter By CPU Time Dialog window

The Filter By Call Counts Dialog window includes the following options:

  • show arcs with the most call counts

  • show arcs with the least call counts

  1. Select the option you want (show arcs with the most call counts is the default).

  2. Select the number of call arcs to which you want it applied (1 is the default). If you enter a value in the text field, the slider is updated to that value when you click Apply or OK. For example, to display the 10 call arcs in your application that represented the least number of calls, you would select the show arcs with the least call counts button, and specify 10 with the slider or enter the value 10 in the text field.

  3. Click Apply to show the changes to the function call tree without closing the dialog. Click OK to show the changes and close the dialog.

Including and excluding parent and child functions:

You must understand how parent and child behavior functions behave, and are able to improve their performance, than you can figure out how to analyzing the functions that consume less CPU.

When tuning the performance of your application, you will want to know which functions consumed the most CPU time, and then you will need to ask several questions in order to understand their behavior:

  • Where did each function spend most of the CPU time?

  • What other functions called this function? Were the calls made directly or indirectly?

  • What other functions did this function call? Were the calls made directly or indirectly?

When your application is large, the function call tree will also be large. As a result, the functions that are the most CPU-intensive might be difficult to see in the function call tree. To avoid this situation, use the Filter by CPU option of the Filter menu, which lets you display only the function boxes for the functions that consume the most CPU time. After you have done this, the Function menu for each function lets you Figure 26. The Filter By Call Counts Dialog window

add the parent and descendant function boxes to the function call tree. By doing this, you create a smaller, simpler function call tree that displays the function boxes associated with the most CPU-intensive area of the application.

A child function is one that is directly called by the function of interest. To see only the function boxes for the function of interest and its child functions, do the following:

  1. Place your mouse cursor over the function box in which you are interested, and press the right mouse button. The Function menu appears.

  2. From the Function menu, select the Immediate Children option, and then the Show Child Functions Only option. Xprofiler erases the current display and replaces it with only the function boxes for the function you chose, as well as its child functions.

A parent function is one that directly calls the function of interest. To see only the function box for the function of interest and its parent functions, do the following:

  1. Place your mouse cursor over the function box in which you are interested, and press the right mouse button. The Function menu appears.

  2. From the Function menu, select the Immediate Parents option, and then the Show Parent Functions Only option. Xprofiler erases the current display and replaces it with only the function boxes for the function you chose, as well as its parent functions.

You might want to view the function boxes for both the parent and child functions of the function in which you are interested, without erasing the rest of the function call tree. This is especially true if you chose to display the function boxes for two or more of the most CPU-intensive functions with the Filter by CPU option of the Filter menu (you suspect that more than one function is consuming too much CPU). Do the following:

  1. Place your mouse cursor over the function box in which you are interested, and press the right mouse button. The Function menu appears.

  2. From the Function menu, select the Immediate Parents option, and then the Add Parent Functions to Tree option. Xprofiler leaves the current display as it is, but adds the parent function boxes.

  3. Place your mouse cursor over the same function box and press the right mouse button. The Function menu appears.

  4. From the Function menu, select the Immediate Children option, and then the Add Child Functions to Tree option. Xprofiler leaves the current display as it is, but now adds the child function boxes in addition to the parents.

라이브러리 묶기

Xprofiler 창을 처음 열면 기본으로 실행 파일과 그에 연결된 라이브러리의 함수 상자가 묶여(clustered) 있습니다.

Xprofiler는 각 라이브러리의 호출 트리를 클러스터에 넣을 때 줄여 그리므로, 특정 함수 상자의 이름표를 자세히 보려면 묶음을 풀어야 합니다.

묶음을 풀거나 펼친(expanded) 상태에서는 묶거나 접은(collapsed) 상태보다 각 함수를 훨씬 자세히 볼 수 있습니다. 하려는 일에 따라 화면을 묶거나 풀어야 합니다.

응용 프로그램이 공유 라이브러리 안의 함수를 부르면 실행 파일 함수와 공유 라이브러리 함수의 상자가 모두 나와 창이 붐빌 수 있습니다. 그래서 가장 중요한 부분에 집중하도록 각 라이브러리의 함수 상자를 라이브러리 클러스터라는 한 영역에 모을 수 있습니다.

원문 그림은 hello_world 응용 프로그램의 함수 상자 묶음을 푼 모습입니다.

함수 묶기

함수 묶음이 풀려 있으면 Filter 메뉴의 Cluster Functions by Library를 고릅니다. 응용 프로그램 안의 라이브러리가 각자의 클러스터 상자 안에 나타납니다.

묶은 뒤에는 각 클러스터 상자를 더 작게 접을(collapse) 수 있습니다.

  1. 클러스터 상자 가장자리에 마우스를 올리고 오른쪽 단추를 누릅니다. Cluster Node 메뉴가 나옵니다.
  2. Collapse Cluster Node를 고릅니다. 클러스터 상자와 그 내용이 작은 녹색 상자로 나타납니다. 원문 그림에서는 /lib/profiled/libc.a:shr.o 라이브러리를 접었습니다.

클러스터 상자를 원래대로 펼치려면 다음과 같이 합니다.

  1. 접힌 클러스터 상자에 마우스를 올리고 오른쪽 단추를 누릅니다.
  2. Expand Cluster Node를 고릅니다. 클러스터 상자와 그 내용이 다시 나타납니다.

함수 묶음 풀기

함수가 묶여 있으면 Filter 메뉴의 Uncluster Functions를 고릅니다. 클러스터 상자가 사라지고 각 라이브러리의 함수 상자가 펼쳐져 창을 채웁니다.

함수가 묶여 있을 때 클러스터 상자를 하나 이상(전부는 아님) 없앨 수도 있습니다. 예를 들어 실행 파일의 함수만 풀고 공유 라이브러리는 클러스터 상자 안에 두려면 다음과 같이 합니다.

  1. 실행 파일이 든 클러스터 상자의 가장자리에 마우스를 올리고 오른쪽 단추를 누릅니다.
  2. Remove Cluster Box를 고릅니다. 클러스터 상자가 없어지고 실행 파일 함수의 상자와 호출 호가 자세히 나타납니다. 공유 라이브러리의 함수 상자와 호출 호는 클러스터 상자 안에 남으며, 풀린 실행 파일 함수 상자에 자리를 내주려고 작아집니다. 원문 그림은 hello_world 실행 파일의 클러스터 상자를 없애고 공유 라이브러리는 클러스터 상자 안에 남긴 모습입니다.
영어 원문

Clustering libraries

When you first open the Xprofiler window, by default, the function boxes of your executable file, and the libraries associated with it, are clustered.

Because Xprofiler shrinks the call tree of each library when it places it in a cluster, you must uncluster the function boxes if you want to look closely at a specific function box label.

You can see much more detail for each function, when your display is in the unclustered or expanded state, than when it is in the clustered or collapsed state. Depending on what you want to do, you must cluster or uncluster (collapse or expand) the display.

The Xprofiler window can be visually crowded, especially if your application calls functions that are within shared libraries; function boxes representing your executable functions as well as the functions of the shared libraries are displayed. As a result, you might want to organize what you see in the Xprofiler

window so you can focus on the areas that are most important to you. You can do this by collecting all the function boxes of each library into a single area, known as a library cluster.

The following figure shows the hello_world application with its function boxes unclustered.

Clustering functions

If the functions within your application are unclustered, you can use an option of the Filter menu to cluster them. To do this, select the Filter menu and then the Cluster Functions by Library option.

The libraries within your application appear within their respective cluster boxes.

After you cluster the functions in your application you can further reduce the size (also referred to as collapse) of each cluster box by doing the following:

  1. Place your mouse cursor over the edge of the cluster box and press the right mouse button. The Cluster Node menu appears. Figure 27. The Xprofiler window with function boxes unclustered

  2. Select the Collapse Cluster Node option. The cluster box and its contents now appear as a small solid green box. In the following figure, the /lib/profiled/libc.a:shr.o library is collapsed.

To return the cluster box to its original condition (expand it), do the following:

  1. Place your mouse cursor over the collapsed cluster box and press the right mouse button. The Cluster Node menu appears.

  2. Select the Expand Cluster Node option. The cluster box and its contents appear again.

Unclustering functions

If the functions within your application are clustered, you can use an option of the Filter menu to uncluster them. To do this, select the Filter menu, and then the Uncluster Functions option.

The cluster boxes disappear and the functions boxes of each library expand to fill the Xprofiler window. Figure 28. The Xprofiler window with one library cluster box collapsed

If your functions have been clustered, you can remove one or more (but not all) cluster boxes. For example, if you want to uncluster only the functions of your executable file, but keep its shared libraries within their cluster boxes, you would do the following:

  1. Place your mouse cursor over the edge of the cluster box that contains the executable and press the right mouse button. The Cluster Node menu appears.

  2. Select the Remove Cluster Box option. The cluster box is removed and the function boxes and call arcs that represent the executable functions, now appear in full detail. The function boxes and call arcs of the shared libraries remain within their cluster boxes, which now appear smaller to make room for the unclustered executable function boxes. The following figure shows the hello_world executable file with its cluster box removed. Its shared library remains within its cluster box.

함수 호출 트리에서 특정 객체 찾기

복잡한 프로그램에서 특정 함수 몇 개에 관심이 있으면 함수 호출 트리에서 해당 함수 상자를 찾는 데 도움이 필요할 수 있습니다.

함수 하나를 찾고 이름을 안다면 Utility 메뉴의 Locate Function By Name을 씁니다.

  1. Utility 메뉴에서 Locate Function By Name을 고릅니다. Search By Function Name Dialog 창이 나옵니다.
  2. Enter Function Name 필드에 찾을 함수 이름을 입력합니다. 이름은 공백이 없는 연속된 문자열이어야 합니다.
  3. OK나 Apply를 누릅니다. 함수 호출 트리에서 해당 함수 상자가 강조 표시(빨간색)되고 그 위치로 확대됩니다. 트리 전체를 다시 보려면 View 메뉴의 Overview를 씁니다.

관심 있는 함수와 그에 관련된 특정 함수의 상자만 보고 싶을 수 있습니다. 예를 들어 관심 있는 함수를 직접 부른 모든 함수를 보고 싶은데, 트리 전체에서는 그 상자들을 떼어 보기 어려울 수 있습니다. 그럴 때는 그 상자들과 관심 있는 함수만 따로 보여 줍니다.

함수마다 메뉴가 있으며, Function 메뉴로 관심 있는 함수의 다음 함수들을 볼 수 있습니다.

  • 부모 함수(관심 있는 함수를 직접 부르는 함수)
  • 자식 함수(관심 있는 함수가 직접 부르는 함수)
  • 조상 함수(관심 있는 함수를 직접 또는 간접으로 부를 수 있는 함수)
  • 자손 함수(관심 있는 함수가 직접 또는 간접으로 부를 수 있는 함수)
  • 같은 순환(cycle)에 속한 함수

이 항목을 쓰면 현재 화면을 지우고 관심 있는 함수와 지정한 종류의 함수 상자만 보여 줍니다.

부모 함수 찾아 보기

부모는 관심 있는 함수를 직접 부르는 함수입니다.

  1. 관심 있는 함수 상자를 오른쪽 클릭합니다. Function 메뉴가 나옵니다.
  2. Immediate Parents, Show Parent Functions Only를 고릅니다. 관심 있는 함수와 그 부모 함수의 상자만 다시 그립니다.

자식 함수 찾아 보기

자식은 관심 있는 함수가 직접 부르는 함수입니다.

  1. 관심 있는 함수 상자를 오른쪽 클릭합니다.
  2. Immediate Children, Show Child Functions Only를 고릅니다. 관심 있는 함수와 그 자식 함수의 상자만 다시 그립니다.

조상 함수 찾아 보기

조상은 관심 있는 함수를 직접 또는 간접으로 부를 수 있는 함수입니다.

  1. 관심 있는 함수 상자를 오른쪽 클릭합니다.
  2. All Paths To, Show Ancestor Functions Only를 고릅니다. 관심 있는 함수와 그 조상 함수의 상자만 다시 그립니다.

자손 함수 찾아 보기

자손은 관심 있는 함수가 직접 또는 간접으로 부를 수 있는(닿을 수 있는) 함수입니다.

  1. 관심 있는 함수 상자를 오른쪽 클릭합니다.
  2. All Paths From, Show Descendant Functions Only를 고릅니다. 관심 있는 함수와 그 자손 함수의 상자만 다시 그립니다.

순환에 속한 함수 찾아 보기

관심 있는 함수와 같은 순환(cycle)에 속한 함수를 찾으려면 다음과 같이 합니다.

  1. 관심 있는 함수 상자를 오른쪽 클릭합니다.
  2. All Functions on the Cycle, Show Cycle Functions Only를 고릅니다. 관심 있는 함수와 그 순환에 속한 다른 모든 함수만 다시 그립니다.
영어 원문

Locating specific objects in the function call tree

If you are interested in one or more specific functions in a complex program, you might need help locating their corresponding function boxes in the function call tree.

If you want to locate a single function, and you know its name, you can use the Locate Function By Name option of the Utility menu. To locate a function by name, do the following: Figure 29. The Xprofiler window with one library cluster box removed

  1. Select the Utility menu, and then the Locate Function By Name option. The Search By Function Name Dialog window appears.

  2. Type the name of the function you want to locate in the Enter Function Name field. The function name you type here must be a continuous string (it cannot include blanks).

  3. Click OK or Apply. The corresponding function box is highlighted (its color changes to red) in the function call tree and Xprofiler zooms in on its location. To display the function call tree in full detail again, go to the View menu and use the Overview option.

You might want to see only the function boxes for the functions that you are concerned with, in addition to other specific functions that are related to it. For example, if you want to see all the functions that directly called the function in which you are interested, it might not be easy to separate these function boxes when you view the entire call tree. You would want to display them, as well as the function of interest, alone.

Each function has its own menu. Through the Function menu, you can choose to see the following for the function you are interested in:

  • Parent functions (functions that directly call the function of interest)

  • Child functions (functions that are directly called by the function of interest)

  • Ancestor functions (functions that can call, directly or indirectly, the function of interest)

  • Descendant functions (functions that can be called, directly or indirectly, by the function of interest)

  • Functions that belong to the same cycle

When you use these options, Xprofiler erases the current display and replaces it with only the function boxes for the function of interest and all the functions of the type you specified.

Locating and displaying parent functions

A parent is any function that directly calls the function in which you are interested.

To locate the parent function boxes of the function in which you are interested:

  1. Click the function box of interest with the right mouse button. The Function menu appears.

  2. From the Function menu, select Immediate Parents then Show Parent Functions Only. Xprofiler redraws the display to show you only the function boxes for the function of interest and its parent functions.

Locating and displaying child functions

A child is any function that is directly called by the function in which you are interested.

To locate the child functions boxes for the function in which you are interested:

  1. Click the function box of interest with the right mouse button. The Function menu appears.

  2. From the Function menu, select Immediate Children then Show Child Functions Only. Xprofiler redraws the display to show you only the function boxes for the function of interest and its child functions.

Locating and displaying ancestor functions

An ancestor is any function that can call, directly or indirectly, the function in which you are interested.

To locate the ancestor functions:

  1. Click the function box of interest with the right mouse button. The Function menu appears.

  2. From the Function menu, select All Paths To then Show Ancestor Functions Only. Xprofiler redraws the display to show you only the function boxes for the function of interest and its ancestor functions.

Locating and displaying descendant functions

A descendant is any function that can be called, directly or indirectly, by the function in which you are interested.

To locate the descendant functions (all the functions that the function of interest can reach, directly or indirectly):

  1. Click the function box of interest with the right mouse button. The Function menu appears.

  2. From the Function menu, select All Paths From then Show Descendant Functions Only. Xprofiler redraws the display to show you only the function boxes for the function of interest and its descendant functions.

Locating and displaying functions on a cycle

Review the following steps to located and display function on a cycle.

To locate the functions that are on the same cycle as the function, complete the following steps:

  1. Click the function box of interest with the right mouse button. The Function menu appears.

  2. From the Function menu, select All Functions on the Cycle then Show Cycle Functions Only. Xprofiler redraws the display to show you only the function of interest and all the other functions on its cycle.

자주 쓰는 형태

bash
cc -pg -g -o myprog myprog.c       # 프로파일링(-pg)과 소스 줄(-g)
./myprog                            # gmon.out 생성
xprofiler myprog gmon.out -disp_max 50 &
gprof myprog gmon.out > myprog.gprof   # X 화면이 없으면 같은 데이터를 텍스트로