Would you like to tell us how we are doing?

You bet No thanks

Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Optimizing code using the Profiler View

The Profiler View collects the following information for the specified code area:

  • Percentage of time spent to the current point of execution
  • Number of objects created
  • Size of objects created
  • Number of objects committed
  • Number of wakeups

You can improve the reliability of results and computer performance when you run the Profiler View by closing other Windows applications and by increasing the heap memory in Eclipse to 512 MB (see Specify heap memory for Eclipse).

Specify Profiler View options

  1. In the Package Explorer view, right-click a BlackBerry device application project.
  2. Click Debug As > BlackBerry Simulator.
  3. Click BlackBerry > Load Project on Device.
  4. On the Window menu, click Show View > Other.
  5. Expand the BlackBerry folder.
  6. Click BlackBerry Profiler View.
  7. Click OK.
  8. In the BlackBerry Profiler View, click Setup Options.

Profiler View options

Drop-down list

Option

Description

Method attribution

Cumulative

The Profiler View calculates the time spent executing bytecode in a method and all methods that are invoked by that method.

In method only

The Profiler View calculates the time spent executing bytecode in the specified method only. The timer stops when another method is invoked.

What to profile

Time (clock ticks)

The Profiler View measures execution time (measured in clock ticks).

 

Number of objects created

The Profiler View calculates the number of objects that are created.

 

Size of objects created

The Profiler View measures the size of objects that are created.

 

Number of objects committed

The Profiler View calculates the number of committed objects.

 

Size of objects committed

The Profiler View measures the size of committed objects.

 

Number of objects moved to RAM

The Profiler View calculates the number of objects that are moved into memory.

 

Size of objects moved to RAM

The Profiler View measures the size of objects that are moved into memory.

 

User Counting

The Profiler View calculates user counting.

 

Number of wakeups

The Profiler View measures the number of times that the application caused the device to wake up from standby since the process started.

Generate Profiler data

  1. Specify a breakpoint at the beginning and end of the section of code that you want to profile.
  2. On the Run menu, click Debug As > BlackBerry Simulator Debug As > BlackBerry Device.
  3. In the BlackBerry Smartphone Simulator, on the BlackBerry device, run the application. The debugging tool pauses the application when it reaches the first breakpoint.
  4. In Eclipse, on the Window menu, click Show View > Other.
  5. Expand the BlackBerry folder.
  6. Click BlackBerry Profiler View.
  7. Click OK.
  8. In the BlackBerry Profiler View, click Setup Options.
  9. In the Profiler Options dialog box, select the type of method attribution and the type of information that you want to profile.
  10. Click OK.
  11. Press F8 to resume program execution.

    The debugging tool pauses the application when it reaches the second breakpoint.

  12. In the BlackBerry Profiler View, click Refresh.

    The Profiler retrieves the data. The Profiler data is not cleared, so when you run an application again, it adds to the data.

  13. To save the contents of the profiler pane to a comma-separated values (.csv) file, in the BlackBerry Profiler View, click Save.

Viewing Profiler data

The BlackBerry Profiler View has three tabs. Each tab displays details about an item of execution (such as a method), the percentage of time spent running the item, and the number of times that the item was run.

Tab

Description

Summary

The Summary tab displays general statistics about the system and the garbage collector.

This tab displays the percentage of time that the BlackBerry JVM has spent idle, executing code, and performing quick and full garbage collection. The Percent column displays the percentage of total BlackBerry JVM running time, including idle time and collection time.

Method

The Method tab displays a list of modules, sorted either by the information that you are profiling or by the number of times each item has been executed.

On this tab, the Percent column displays the percentage of BlackBerry JVM execution time only, not including idle time and garbage collection time.

Source

The Source tab displays the source lines of a single method. You can navigate through the methods that invoke, and are invoked by, that method.

You can expand a source line to show individual bytecode.

You can further expand any bytecode that corresponds to a method invocation to show the target or targets of the method invocation.

View Profiler data

  1. On the Window menu, click Show View > Other.
  2. Expand the BlackBerry folder.
  3. Click BlackBerry Profiler View.
  4. Click OK.

Save the contents of the BlackBerry Profiler View to a .csv file

  1. In the BlackBerry Profiler View, click Refresh.
  2. Click Save data to a .csv file.
  3. Select a location and type a name for the file.
  4. Click Save.

The BlackBerry Java Plug-in for Eclipse saves the contents of the BlackBerry profiler view to a comma-separated values (.csv) file. Contents are saved in the same format that they are displayed in.

Save the contents of the BlackBerry Profiler View to an .xml file

  1. In the BlackBerry Profiler View, click Refresh.
  2. Click Save data to a .xml file.
  3. Select a location and type a name for the file.
  4. Click Save.

The BlackBerry Java Plug-in for Eclipse saves the contents of the BlackBerry Profiler View to an XML file.