User guide
Profiling Execution Performance
Profiling C Code
To use the GNU profiler, you must compile and link your program with the profiling library,
execute the program to generate a gmon.out profile data file, and run gprof to parse the
profile data. The following sections describe how to accomplish the tasks.
To collect profiling data:
1. Switch to the Nios II C/C++ perspective, if necessary.
2. Right-click your project in the Nios II C/C++ Projects view, and then click System
Library Properties.
3. In the Properties dialog box, click System Library.
4. Turn on Link with profiling library.
5.
6. Click OK.
7. Right-click your project in the Nios II C/C++ Projects view, point to Run As, and
then click Nios II Hardware.
After program execution completes, the file <project directory>/<build configuration
directory>/gmon.out contains the profiling information.
Note: Execution must return from main()
to create the file; if you terminate the run or
debug session, all profiling information is lost.
To analyze profiling data:
The nios2-elf-gprof utility converts the binary gmon.out data file and displays the
profiling information in a readable format. You can run the nios2-elf-gprof utility
automatically with the Profiling perspective in the Nios II IDE.
To view the profiling data, perform the following steps:
1. In the Nios II C/C++ Projects view, locate the generated gmon.out file in the
<build configuration directory> (typically Release or Debug) .
2. Double-click the gmon.out file to automatically switch to the Profiling perspective
and display the gmon.out data.
You can also run the nios2-elf-gprof utility from the command line.
Related Nios II IDE Help Topics
About Profiling with the Nios II IDE
Profiling Perspective
Call Hierarchy View (Profiling Perspective)
Editor View (Profiling Perspective)
73