For this particular situation for example, you might have a single-threaded
application that performs badly for a specific test case, and you
want to understand the reason(s) why, and try to attempt to
optimize it, if possible.
Before you start:
The application you use must have been compiled from an IDE
project.
You must have a launch configuration that runs the application
with some existing test data.
To profile the application, follow these steps:
Create an Application Profiler session using the IDE launch
configuration:
In the Application
Profiler options, enable
Function Instrumentation,
and click Apply.
Return to the Application
Profiler tab in the Launch
configuration dialog and click
Run again. There will be no
error message this time.
The IDE changes to the
Application Profiling perspective, populates the
session view, and shows the Execution Time view,
which dynamically changes.
After the application terminates, inspect the Application
Profiler results:
In the Execution Time view, click the
Menu icon and select
Show Caller Tree.
The
active page shows the Tree containing the list of
functions being called.
Expand the root node and observe the functions
it called with times, percentages, and call times.
Continue expanding until you encounter any
suspicious functions that consume the CPU time.
Now, you can investigate why the certain
functions consume the CPU time.
Select the function and perform the Show Caller
Tree action.
View the changes to show the function that you want to
investigate as the root, and its callers as children
(Caller Tree mode). Now, you might notice that this
function is called from other places as well;
however, you need to investigate its total
contributions versus the amount of CPU it
consumes.
Select another function from the list, right-click on the
function and select Show Reverse
Calls from the menu.
View the changes to show this function as the root in the
hierarchy, and its calling functions as children (Show
Call Tree mode).
Observe the number of times that this function is called, the
percentage of CPU time it consumes, the number of times
its child (children) is called, and the total time.
Open the source code for the function to confirm any
suspicions, and to perform any necessary edits to the
code.
Next, you can confirm your results by running
another profiling session, and then using the
Comparing profiles
feature to compare the results.
Run the launch configuration again.
Wait until the application terminates.
In the Profile Sessions view, right-click on a
session and select Compare.
The IDE opens a view where you can see the
total time compared to the other session time with
the percentage of improvements (a green arrow
pointing downward).
Return to your normal development cycle by disabling the
Application Profiler tool in the launch configuration.
Note: There's no need to change your compile
options.