Optimizing code using the Profiler

The profiler application collects the following information for the specified code area:
  • percentage of time spent to the current point of execution.
  • number objects created.
  • size of objects created.
  • number of objects committed.
You can improve the reliability of results and computer performance when you run the profiler application by closing other Windows® applications and increasing the heap memory in Eclipse® to 512 MB (see Specify heap memory for Eclipse) .

Specify profiler options

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

Profiler options

Drop-down list

Option

Description

Method attribution

Cumulative

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

In method only

The profiler application 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 application measures execution time (measured in clock ticks).

 

Number of objects created

The profiler application calculates the number of objects that are created.

 

Size of objects created

The profiler application measures the size of objects that are created.

 

Number of objects committed

The profiler application calculates the number of committed objects.

 

Size of objects committed

The profiler application measures the size of committed objects.

 

Number of objects moved to RAM

The profiler application calculates the number of objects that are moved into memory.

 

Size of objects moved to RAM

The profiler application measures the size of objects that are moved into memory.

 

User Counting

The profiler application calculates user counting.

Back To Top

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.
  3. In the BlackBerry® Smartphone Simulator, 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 retreives the data. Profiler data is not cleared, so running an application again 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
Back To Top

Viewing Profiler data

The BlackBerry Profiler Pane 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® Java® Virtual Machine 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.

Back To Top

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.
Back To Top

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.
Back To Top

Was this information helpful? Send us your comments.