Analyze Code Fragment Performance
This command allows you to specify and to measure the time it takes to execute an
arbitrary piece of code within one method, or the whole method. By analyzing a code fragment
rather than the entire application, the profiling overhead is greatly reduced. The absolute results that
you obtain in this mode are closest to the real runtime performance, since the
instrumentation is the most lightweight.
How To Analyze Code Fragment Performance
- Choose Profile -> Profile Main Project (
)
from the main menu.
- Select Analyze Code Fragment Performance in the Select Profiling Task dialog box.
- Click the Select Code Fragment button to open the Specify Code Fragment dialog box.
- Click the Select button and locate the class containing the fragment you would like to analyze.
- Do one of the following:
- Select Whole Method and choose a method from the list in the combo box
- Select Part of Method Code and enter the lines of the source code to profile
- Click OK.
- Click Run at the bottom of the dialog box to launch the application and
start the task.
When you click Run, the target application launches and the Analyze Code Fragment Performance command starts.
To display profiling results, click the Live Results button (
)
in the Profiler window. The results are displayed in the Profiling Results tab.
(Click here
to see an example of Code Fragment Performance results.)
How To Specify a Code Fragment Using the Pop-up Menu
You can specify a fragment using the pop-up menu item
Tools -> Add as a Profiling Code Fragment in the Projects Window.
When you specify the code fragment in this way, you can choose to add
it to the settings configuration for Analyze Performance: Code Fragment, or add it to a new settings configuration to be used
in Custom Profiling.
- In the Projects Window, locate the method which contains the code fragment you want to instrument.
- Right-click on the method in the Projects window.
- Choose Tools -> Add as Profiling Code Fragment from the pop-up menu.
This opens the Select Settings Configuration dialog box.
- In the Select Settings Configuration dialog box, choose one of the configuration settings or
create a new one by selecting "<Create new configuration>".
The class and its methods now appear in the pull-down lists in the Specify Code Fragment dialog box
when you choose Analyze Code Fragment Performance, as well as in the list of code fragments in Custom Profiling -> Profile CPU -> Code Fragment.
See also