About tracing and profiling an application
You use tracing and profiling to debug and tune an application.
When you run an application, you can generate an execution trace
file. You use the trace file to create a profile of your application.
The profile shows you which functions and events were called
by which other functions and events, how often they were called,
when garbage collection occurred, when objects were created and
destroyed, and 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.
PBDebug tracing You can also generate a simple text trace file without timer
values by checking Enable PBDebug Tracing in the System Options
dialog box.
For more about PBDebug, see “Generating a trace file
without timing information”.
When you can trace an application
You can create a trace file when you run an application in
the PowerBuilder environment, and when you run an executable outside
PowerBuilder. For machine-code executable files, the trace file
is generated only if you check the Trace Information check box when
you build the executable.
When you run an application with tracing turned on, PowerBuilder
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.
Creating profiles
After you have generated a trace file, you can create several
different profiles or views of the application by extracting different
types of information from the trace file.
PowerBuilder provides three profiling tools that create profiles
(views) of the application for you, but you can also create your
own analysis tools.
Using profiling to tune an application
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, routines being called
that you did not expect to call, or routines that are not being
called at all. Follow these suggestions for tuning an application:
- The database connection process is often slow. Although
you might not be able to speed this up, you might be able to enhance
the user’s perception of performance by moving the database
connection process to a different place in your application. - Use profiling to tune algorithms. Algorithmic fixes
will yield greater performance enhancements than changing single
lines of code. - Optimizing an inefficient function is not as effective
as removing unneeded calls to that function. - Focus on optimizing the routines that are called
most often. - If you cannot speed up a routine, consider adding
some user feedback, such as updating MicroHelp or displaying a progress
bar.