Analyze Code Fragment Perfromance

Home > Profiling Tasks

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

  1. Choose Profile -> Profile Main Project ( Profile Main Project ) from the main menu.
  2. Select Analyze Code Fragment Performance in the Select Profiling Task dialog box.
  3. Click the Select Code Fragment button to open the Specify Code Fragment dialog box.
  4. Click the Select button and locate the class containing the fragment you would like to analyze.
  5. 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
  6. Click OK.
  7. 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 ( Live Results ) in the Profiler window. The results are displayed in the Code Fragment tab in the Profiling Results tab.
(Click here to see an example of the Code Fragment tab results.)

How To Specify a Code Fragment Using the Contextual Menu

You can specify a fragment using the contextual 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.

  1. In the Projects Window, locate the method which contains the code fragment you want to instrument
  2. Right-click on the method in the Projects window
  3. Choose Tools -> Add as Profiling Code Fragment from the contextual menu

    This opens the Select Settings Configuration dialog box

  4. 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


Project Features

About this Project

Profiler was started in November 2009, is owned by Tomas Hurka, and has 62 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20160708.bf2ac18). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
Please Confirm