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
-
In the
Package Explorer view, right-click a
BlackBerry® device application project.
-
Click
Debug As > BlackBerry Simulator.
-
On the
Window menu, click
Show View > Other.
-
Expand the
BlackBerry folder.
-
Click
BlackBerry Profiler View.
-
Click
OK.
-
In the
BlackBerry Profiler View, click
Setup Options.
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.
|
Generate Profiler data
-
Specify a breakpoint at the beginning and end of the section of
code that you want to profile.
-
On the
Run menu, click
Debug As > BlackBerry
Simulator.
-
In the
BlackBerry® Smartphone Simulator, run the
application. The debugging tool pauses the application when it reaches the
first breakpoint.
-
In
Eclipse®, on the
Window menu, click
Show View > Other.
-
Expand the
BlackBerry folder.
-
Click
BlackBerry Profiler View.
-
Click
OK.
-
In the
BlackBerry Profiler View, click
Setup Options.
-
In the
Profiler Options dialog box, select the type
of method attribution and the type of information that you want to profile.
-
Click OK.
-
Press
F8 to resume program execution.
The debugging tool pauses the application when it reaches
the second breakpoint.
-
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.
-
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 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.
|
View Profiler data
- On the Window menu, click Show View > Other.
- Expand the BlackBerry folder.
- Click BlackBerry Profiler View.
- Click OK.
Save the contents of the
BlackBerry
profiler view to a .csv file
- In the BlackBerry Profiler View, click Refresh.
- Click Save data to a .csv file.
- Select a location and type a name for the file.
- 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.
Was this information helpful? Send us your comments.