Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.3 for NetBeans on Windows
  Go To Table Of Contents
Go To Index


9 Profiling Applications

The Oracle Java ME SDK supports performance profiling for Java ME applications. The profiler keeps track of every method in your application. For a particular emulation session, it figures out how much time was spent in each method and how many times each method was called.

The SDK supports offline profiling. Data is collected during the emulation session. After you close the emulator you can export the data to a .nps file you can load and view later. As you view the snapshot you can investigate particular methods or classes and save a customized snapshot (a .png file) for future reference.

You can start a profiling session from the NetBeans IDE, as described in "Collecting and Saving Profiler Data in the IDE" or from the command line, as discussed in "Command Line Profiling." It is important to understand that profiling data produced from the command line has a different format (*.prof) than data produced from the NetBeans profiler (a.nps file).


This feature might slow the execution of your application.

Profiling data from Oracle Java ME SDK projects is displayed in a tab in the IDE. The NetBeans IDE has a Profiling window (Window > Profiling > Profiler) but it is not discussed here. Because only performance profiling is supported, the Profiler window has limited usefulness for Java ME applications.

9.1 Collecting and Saving Profiler Data in the IDE

This procedure describes interactive profiling. To run profile an application from the command line, see "Command Line Profiling."


The profiler maintains a large amount of data, so profiled MIDlets place greater demands on the heap. To increase the Heapsize property, see "Setting Device Properties."

  1. In the Projects widow, right-click the project you want to profile and select Profile.

    If this is the first time profiling this project you are prompted to integrate the profiler. Click Yes to perform the integration.

  2. Figure 9-1 Profiling of AudioDemo

    Description of Figure 9-1 follows
    Description of "Figure 9-1 Profiling of AudioDemo"

    The profiler attaches. You are prompted for the running options. Click Yes.

    Figure 9-2 Attaching the Profiler

    Description of Figure 9-2 follows
    Description of "Figure 9-2 Attaching the Profiler"

    Check the CPU Profiler, and optionally check Profile System Classes. Press Run.

    The emulator opens with your application running.

  3. Interact with the application MIDlet(s) as you normally would.

    The data is automatically displayed in a tab labeled cpu:time, where time is the time the data was displayed.

    Figure 9-3 The Profiling Tab with Combined View Selected

    Description of Figure 9-3 follows
    Description of "Figure 9-3 The Profiling Tab with Combined View Selected"

  4. To export the profile data, press the Export icon and supply a .nps file name and location. This data can be reloaded at a later time. See "Loading a .nps File."

    Figure 9-4 Exporting Profile Data

    Description of Figure 9-4 follows
    Description of "Figure 9-4 Exporting Profile Data"

  5. To the save the current view to a .png file, press the "Save current view to image" icon and supply a file name and location.

    Figure 9-5 Saving the Current View

    Description of Figure 9-5 follows
    Description of "Figure 9-5 Saving the Current View"

9.2 Loading a .nps File

A previously exported .nps file ("Collecting and Saving Profiler Data in the IDE") can be loaded at a later time.

Follow these steps to retrieve profile data:

  1. Click the Profile menu and select Load Snapshot... .

  2. Choose the .nps file.

The Profiler opens in its own tab labeled cpu:filename. Click the Info tab at the bottom of the Method table to view the snapshot.


The profiling values obtained from the emulator do not reflect actual values on an external device.

9.3 Importing a .prof File

A .prof file created from the command line ("Command Line Profiling") can be loaded from the NetBeans IDE. The following example shows what a command line profiling session command might look like:

emulator.exe -Xdevice:JavaMEPhone1 
-Xdescriptor:"C:\Documents and Settings\username\My Documents\NetBeansProjects\UIDemo\dist\Games.jad" -Xprofile:file=C:\temp\

Files created from the command line are formatted differently from the .nps files created as described in "Collecting and Saving Profiler Data in the IDE."

Follow these steps to retrieve command line profile data from the IDE:

  1. Click the File menu and select Open File... .

  2. Browse to the .prof file you want and click Open.

    The Profiler displays the data in its own tab labeled cpu:filename.

When the file has been loaded it can be saved in the .nps format. Click the Export to... icon and supply a file name and location.