11.5.6. Profiling example: sorts

The sorts application can be found in the Examples subdirectory of the ARM Software Development Toolkit. Copy the files into your working directory.

PC sampling information

If you are using the command-line tools:

  1. Compile the sorts.c example program:


    armcc -Otime -o sorts sorts.c

  2. Start armsd and load the executable:


    armsd sorts

  3. Turn profiling on:


    profon

  4. Run the program as normal:


    go

  5. When execution completes, write the profile data to a file using the ProfWrite command:


    ProfWrite sort1.prf

  6. Exit armsd:


    Quit

  7. Generate the profile for the collected data by entering at the system prompt:


    armprof sort1.prf > prof1

    The profiler generates the report and sends the output to text file prof1 that you can examine.

If you are using the Windows toolkit:

  1. If you use ADW and are running APM then:

    1. Select Open from the Project menu to load the project file sorts.apj into APM.

    2. Build the project by clicking the Force Build button. The project is built and any messages are displayed in the build log.

    3. Load the debugger by clicking the Debug button. ADW is started and the application is loaded.

    If you use ADU then:

    1. Compile and link the sorts.c example program with the command:armcc -Otime -o sorts sorts.c

    2. Start ADU.

    3. Select Load Image... from the File menu to load the sorts.exe program file into ADU.

  2. Select Options  ? Profiling  ? Toggle Profiling to turn profiling on in ADW or ADU.

  3. Click Go to start the program.

    The program runs and stops at the breakpoint on main.

  4. Click Go again.

    The program resumes execution.

  5. When execution completes, select Options  ? Profiling  ? Write to File to write the profile data to the file sort1.prf.

  6. Exit ADW or ADU and start a DOS session. Make the profile directory the current directory.

  7. Generate the profile for the collected profile data by entering the following at the system prompt:


    armprof sort1.prf > prof1

    armprof generates the profile report and sends its output to text file prof1 that you can examine.

Call graph information

If you are using the command-line tools:

  1. Restart the debugger:


    armsd

  2. Load the sorts program into armsd with the /callgraph option:


    load/callgraph sorts

    /callgraph tells armsd to prepare an image for function call count profiling by adding code that counts the number of function calls.

  3. Turn profiling on:


    ProfOn

  4. Run the program as normal:


    go

  5. When execution completes, write the profile data to a file:


    ProfWrite sort2.prf

  6. Exit armsd:


    Quit

  7. Generate the profile by entering the following at the system prompt:


    armprof -Parent sort2.prf > prof2

    The -Parent option instructs armprof to include information about the callers of each function. armprof generates the profile report and sends its output to text file prof2, that you can examine.

If you are using the Windows tools:

  1. If you are using APM and ADW, reload the debugger by clicking the Debug button on the APM toolbar. If you are using ADU, start ADU.

  2. Select Options  ? Profiling  ? Call Graph Profiling to turn on call graph profiling.

  3. Click Reload to reload the image. This forces call graph profiling to take effect.

  4. Select Options  ? Profiling  ? Toggle Profiling to turn on profiling in ADW or ADU.

  5. Click Go to start the program.

    The program runs and stops at the breakpoint on main.

  6. Click Go again.

    The program resumes execution.

  7. When execution completes, select Options  ? Profiling  ? Write to file to write the profile data to the file sort2.prf.

  8. Exit ADW or ADU and invoke a DOS session.

  9. Generate the profile by entering the following at the DOS prompt:


    armprof -Parent sort2.prf > prof2

    The -Parent option instructs armprof to include information about the callers of each function. armprof generates the profile report and sends its output to the text file prof2, that you can examine.

Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0040D
Non-Confidential