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


9 Profiling Applications

The 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 Section 9.1, "Collecting and Saving Profiler Data in the IDE", or from the command line, as discussed in Section 13.3.4, "Command Line Profiling". It's important to note that profiling data produced from the command line has a different format (*.prof) than data produced from the NetBeans profiler (a.nps file).

The NetBeans IDE has a Profiling window. Because only performance profiling is supported for Java ME, this feature has limited usefulness for Java ME applications.


This feature might slow the execution of your application.

9.1 Collecting and Saving Profiler Data in the IDE

This procedure describes interactive profiling. (To run and profile an application from the command line, see Section 13.3.4, "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 Section 6.3, "Setting Device Properties".

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

  2. If this is the first time profiling this application you are prompted to integrate the profiler with the project. Click OK to perform the integration.

    Description of prof-integ.gif follows
    Description of the illustration prof-integ.gif

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

    Description of profiler_run.gif follows
    Description of the illustration profiler_run.gif

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

  3. Start your application.

    Interact with the application as you normally would.

  4. Exit the MIDlet.

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

    Description of profiler.gif follows
    Description of the illustration profiler.gif

  5. 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 Section 9.2, "Loading a .nps File".

    Export profile data to a file of your choice.
  6. 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.

    Save a visual snapshot of the profiling session

9.2 Loading a .nps File

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

Follow these steps to retrieve profile data:

  1. Select Profile > Load Snapshot...

  2. Choose the .nps file.

The Profiler opens in its own tab labeled CPU:time.


The profiling values obtained from the emulator do not reflect actual values on a real device.