PreviousNext

Optimize source code using the BlackBerry Profiler

Use the BlackBerry® IDE Profiler tool to optimize your code. The Profiler tool displays the percentage of time spent in each code area to the current point of execution.

Note: To improve the reliability of results when you run the profiler application, exit other Microsoft Windows applications.

Set profile options

    1. In the profile pane, click Options.
    2. On the General tab, set the following options:
      Drop-down list
      Option
      Description

      Method attribution

      Cumulative

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

      In method only

      The profiler calculates the time spent executing bytecode in that method only. The timer stops when a call is made to another method.

      Sort method by

      Count

      The profiler sorts methods in the profile pane by the number of times the item was executed

      Profiled data(selected in "What to profile")

      The profiler sorts methods in the profile pane by the data that is being profiled

      What to profile

      Time (clock ticks)

      The profiler considers execution time (measured in clock ticks).

      Number of objects created

      The profiler considers the number of objects created.

      Size of objects created

      The profiler considers the size of objects created.

      Number of objects committed

      The profiler considers the number of committed objects.

      Size of objects committed

      The profiler considers the size of committed objects.

      Number of objects moved to RAM

      The profiler considers the number of objects moved into memory.

      Size of objects moved to RAM

      The profiler considers the size of objects moved into memory.

      User Counting

      The profiler considers user counting.

    3. To change the colors used for source code highlighting, click the Colors tab .

Generate profile data

    1. Set a breakpoint at the start of the section of code to profile.
    2. Set a breakpoint at the end of the section of code to profile.
    3. On the Debug menu, click Go.
    4. In the BlackBerry® Smartphone Simulator, run the application. The debug tool pauses the application when it reaches the first breakpoint.
    5. On the View menu, click Profile.
    6. In the profile pane, click Options.
    7. Select the type of method attribution, a sorting method, and the type of information to profile.
    8. Click OK.
    9. In the profile pane, click Clear. The profiler data is removed and the running time of Java® code is reset to 0.
    10. On the Debug menu, click Go.
    11. In the BlackBerry Smartphone Simulator, run the application. The debugger pauses the application when it reaches the second breakpoint.
    12. If the profile pane is not visible, on the View menu, click Profile.
    13. In the profile pane, click Refresh. All accumulated profile data is retrieved from the Java VM. Profiler data is not cleared, so running a application again adds to the data.

      · Use profile views to view information about the section of code that you just ran.

    14. Click Save to save the contents of the profile pane to a comma separated values (.csv) file

View profile data

The profile pane has three views. Each view contains details about an item of execution (such as a method), the percentage of time spent running the item, and the number of times the item was run.

Note: To view all accumulated data, click Refresh.

    1. On the View menu, click Profile.
    2. Click one of the following view tabs:
      View
      Description

      Summary

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

      It displays the percentage of time that the Java® VM has spent idle, executing code, and performing quick and full garbage collection. The Percent column displays the percent of total VM running time, including idle and collection time.

      Methods

      The Methods view 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.

      • Expand the All item to see a list of all methods.
      • Expand a specific module to see only its methods.
      • Right-click a method, and then click Profile Source to view source lines in the Source view.
      • Right-click a method, and then click Show Source to view source code in the Edit window.

      In this view, the Percent column displays the percentage of VM execution time only, not including idle and garbage collection time.

      Source

      The Source view displays the source lines of a single method. You can navigate through the methods that call, and are called by, that method.

      The Source view displays the following items:

      • A list of callers to the method, including the number of times that they make the call and the total time spent on these calls
      • A list of source lines for the method and the total time spent on these lines

      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(s) of the method invasion.

      > To view the source code in the Edit window, right-click a line and select Show Source .

      > To follow the history of methods that you have visited in the Source view, click Back and Forward .

Save the contents to a file

    1. In the Profile pane, click Save.
    2. Select a location and type a name for the file.
    3. Click Save.

The contents of the pane are saved to a comma-separated values (.csv) file. Contents are saved as they are displayed.

Clear profile data

> In the profile pane, right-click, and then click Clear.

Related topic


   BlackBerry