Profiling a Free-form Project

In a free-form project, you have to create Ant targets to be able to profile a file or project. You generally want one target in your free-form project's build script for profiling a project and one target for profiling individual files.

The first time that you choose the "Profile Project" or "Profile File" command on a free-form project you will need to create the targets. The IDE can create the targets for you based on the information for the target that is mapped to the Run command for the project. You only need to generate the targets once.

To profile a free-form project perform the following steps.

  1. Set the free-form project as the main project by choosing Run > Set Main Project in the main menu and selecting the project.
  2. Choose Profile > Profile Main Project in the main menu.

    Click Generate in the Profile Project dialog box if you are prompted to generate a target.

  3. Configure the profiling session in the Select Profiling Task dialog. Click Run.

Notes.

For example, the profile-nb target that the IDE generates in ide-targets.xml might look similar to the following.

<?xml version="1.0" encoding="UTF-8"?>
    <project basedir=".." name="YourProjectName">
        <import file="../build.xml"/>
        <target name="-profile-check">
            <startprofiler freeform="true"/>
        </target>
        <!-- TODO: edit the following target according to your needs -->
        <target name="profile-nb" if="profiler.configured" depends="-profile-check">
            <java classname="${mainclass}" dir="." fork="true">
                <classpath>
                    <pathelement path="ClasspathSpecifiedInYourRunTarget"/>
                </classpath>
                <jvmarg line="${agent.jvmargs}"/>
            </java>
        </target>
    </project>

In this example the IDE attempted to guess the runtime classpath for the project.

If you do not have a run target mapped or the IDE otherwise cannot determine the project's classpath or main class, the generated profile target includes "TODO" placeholders for you to fill in these values.

Profiling Free-form Web Projects

Typically the server is started using a startup script, not the java command directly. Therefore you cannot use the <jvmarg .../> element to pass additional argument to it. Instead, you have to modify the server startup script to configure it for profiling.

The recommended approach is to create a new script for starting the server for profiling and use it in the profile target. The Attach Settings dialog box can provide steps to help you modify the startup script. If your target server does not support automatic integration, you can create the script by following the integration steps described in the Attach Settings dialog box. You always have to set up the integration for Local Direct attach.

The other steps for profiling a free-form web project are the same as those above for profiling a standard J2SE projects.

For more about how to profile a free-form project and arguments you can use, see the following document on configuring free-form projects.

See Also
Profiling Using Attach Mode

Legal Notices