In PocketBuilder 2.0.1, you can use tracing and profiling functions to monitor application performance on the desktop or on a handheld device. Tracing and profiling can help you debug and tune an application. You can create a trace file when you run an application from the design-time environment or from a standalone executable at runtime. You use the trace file to create a profile of your application. The trace file must have a PKP extension to be viewed in profiling tools included with PocketBuilder.
When you run an application with tracing turned on, PocketBuilder records a timer value in a data file every time a specific activity occurs. You control when logging begins and ends and which activities are recorded.
PKDebug tracing
PKDebug tracing was available in earlier builds of PocketBuilder
and Pocket PowerBuilder. You can still generate a simple text trace
file without timer values by checking Enable PKDebug Tracing in
the System Options dialog box. Trace files created with PKDebug
tracing have a DBG extension.
For information about PKDebug tracing, see the User’s Guide in the online Help.
There are three kinds of timer: clock, process, and thread. If you do not specify a type of timer, the time at which each activity begins and ends is recorded using the clock timer, which measures an absolute time with reference to an external activity, such as the machine's start-up time. The clock timer measures time in microseconds.
To trace activities on the desktop, you can use process or thread timers, which measure time in microseconds with reference to the start of the process or thread being executed. Clock timers and thread timers are the only kinds of timers supported on handheld devices. If you select the process timer for an application running on a device, the thread timer is used instead.
Both process and thread timers exclude the time taken by any other running processes or threads so that they give you a more accurate measurement of how long the process or thread is taking to execute, but both have a lower resolution than the clock timer.
After you have generated a trace file, you can create several different profiles (views) of the application by extracting different types of information from the trace file. A profile shows you:
Which functions and events were called by which other functions and events
How often functions and events were called
When garbage collection occurred
When objects were created and destroyed
How long each activity took to complete
This information helps you find errors in the application's logic and identify areas that you should rewrite to improve performance.
PocketBuilder provides three profiling tools that create views of the application for you, but you can also create your own analysis tools. Examining the profiles generated by the profiling tools tells you where the application is spending the most time. You can also find routines that are being called too often, being called unexpectedly, or not being called at all.
Viewing profiles from a handheld device
The profiling tools included with PocketBuilder work only
on the desktop. If you use the profiling tools to view a trace file
from a deployment device, you must copy the executable for the application
that created the trace file to a desktop directory. The desktop
directory must have the same path name—with the exception
of the initial drive letter—as the path where the executable resides
on the device. For example, for an application residing in the \Program Files\Tests
directory on a device, you must copy the executable to \Program
Files\Tests on the current drive on the desktop.
You must also copy the PKP trace file from the handheld device. Although you can copy the PKP file to any location on the desktop, when you select the PKP file in a profiling tool, you also set the current drive; therefore you should copy the PKP file and the executable file to the same drive on the desktop.
There are three ways to collect trace information. You can use:
The Profiling tab on the System Options dialog box
A window similar to the Profiling tab
Trace objects and functions
Whichever method you use, you can specify:
The name and location of the trace file and optional labels for blocks of trace data
The kind of timer used in the trace file
The activities you want recorded in the trace file
For more information on collecting and analyzing trace information, see the chapter on tracing and profiling in the User’s Guide in the online Help.
You can use the PowerScript system functions listed in Table 2 to collect information in a trace file. Each of these functions returns a value of type ErrorReturn, an enumerated datatype.
You use the PowerScript functions and PocketBuilder objects listed in Table 3 to analyze the performance of an application; however, this analysis must be performed on the desktop. Each of these functions returns a value of the enumerated datatype ErrorReturn. The objects listed in the table contain information such as the number of times a line or routine was executed, and the amount of time spent in a line or routine and in any routines called from that line or routine.
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |