Support for device skins at design time  Modifications to the Enhanced CAB Generation tool

Release Bulletin PocketBuilder™ 2.0.1

Support for tracing and profiling

Creating a trace file

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.

NotePKDebug 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.

Timer kinds

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.

Creating profiles

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:

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.

NoteViewing 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.

Collecting trace information

There are three ways to collect trace information. You can use:

Whichever method you use, you can specify:

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.

Tracing functions

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.

Table 2: PowerScript trace functions

Use this PowerScript function

To do this

TraceOpen

Open a named trace file and set the timer kind.

TraceEnableActivity

Enable logging of the specified activity.

TraceBegin

Start logging all enabled activities. You can pass an optional label for the trace block.

TraceError

Log a severity level and error message to the trace file.

TraceUser

Log a reference number and informational message to the trace file.

TraceEnd

Stop logging all enabled activities.

TraceDisableActivity

Disable logging of the specified activity.

TraceClose

Close the open trace file.

Profiling functions

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.

Table 3: Desktop-only functions for analyzing performance

Use this function

With this object

To do this

SetTraceFileName

Profiling

Set the name of the trace file to be analyzed.

BuildModel

Profiling

Build a call graph model based on the trace file. You can pass optional parameters that let you track the progress of the build.

RoutineList

Profiling and ProfileClass

Get a list of routines in the model or in a class.

ClassList

Profiling

Get a list of classes in the model.

SystemRoutine

Profiling

Get the name of the routine node that represents the root of the model.

IncomingCallList

ProfileRoutine

Get a list of routines that called a specific routine.

OutgoingCallList

ProfileRoutine and ProfileLine

Get a list of routines called by a specific routine or from a specific line.

LineList

ProfileRoutine

Get a list of lines in the routine in line order.

DestroyModel

Profiling

Destroy the current performance analysis model and all the objects associated with it.





Copyright © 2005. Sybase Inc. All rights reserved. Modifications to the Enhanced CAB Generation tool

View this release bulletin as PDF