 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
|
Profiling and tracing is used mostly at development to find errors and identify performance bottlenecks. The trace engine collect data into file that can be in next analized.The statistics (profile entries) are collected during execution of application. You can start the tracer during development by selecting flag System Options screen :
|
|
|
 |
|
|
|
The trace file (PBT) is analyzed using tools available in PowerBuilder ( till PowerBuilder 7.0 the external application was used to analize profiles) available on Tools tab: The developer can use : Profiling Class View, Profiling Routine View and Profiling Trace View :
|
|
|
|
 |
|
|
|
The Profiling Class View presents statistics about objects instantiated in application. The left panel shows tree of objects and right panel displays statistics. The statistics are vere helpful and it shows number of times every script function is called. Additionally this view is able to present every line of code with information how many the line was called and time of the execution.
|
|
|
|
The Profiling Routine View displays statistics about routine (system or user defined)
|
|
|
|
The previous two tools are appropriate for analizing number of calls and execution times of the routines.
In case the main requirement is to find the most time consuming function or event then decide to use Profiling Trace View. The tool presents routines in the order of the execution with the time of the execution. The routines are presented as it was called from application, so in an easy way you can choose the place that should be tuned. As you see in below screen the most consuming routine is the w_symuluj.ue_symuluj() event. The timing of every routine is for very powerfull, , isn’t ?
|
|
|
|
 |
|
|
|
Using profiling starting from development environment has two disadvantages. At first the profile entries are collected from start to end of the application so it approach can cause many data that have to be analized. At second the trace is available only on development environment and is not so easy to activate profiling in executable.
The PowerBuilder allow collect profile entries programmatically by using special objects and functions. The objects : Profiling , ProfileRoutine, ProfileCall, ProfileClass, ProfileLine, TraceFile, TraceTree, TraceTreeNode with descendands.
If you are interesting in building trace facility in executables please download my examples
|
|
|
|
Another way to generating trace information from PowerBuilder is the PBDebug. This functionality is activated by selecting Enable PBDebug Tracing checkbox in System Options dialog box. The PBDebug generate text files without any time execution statistics like in profiler. The debug trace log can be enabled in development environment or by running application with /pbdebug command line switch. The entries in output file are store in order of executions. For me the output is not very helpfull but every masohist will be enjoyed during analizying one.
|
|
|
|
 |
|
|
|
PBDebug output file example:
Executing instruction at line 4 Executing object function +CREATE for class TRANSACTION, lib entry _TYPEDEF End object function +CREATE for class TRANSACTION, lib entry _TYPEDEF Executing instruction at line 5 Executing object function +CREATE for class DYNAMICDESCRIPTIONAREA, lib entry _TYPEDEF End object function +CREATE for class DYNAMICDESCRIPTIONAREA, lib entry _TYPEDEF Executing instruction at line 6 Executing object function +CREATE for class DYNAMICSTAGINGAREA, lib entry _TYPEDEF End object function +CREATE for class DYNAMICSTAGINGAREA, lib entry _TYPEDEF Executing instruction at line 7 Executing object function +CREATE for class ERROR, lib entry _TYPEDEF End object function +CREATE for class ERROR, lib entry _TYPEDEF End class function +CREATE for class SYMULACJA, lib entry SYMULACJA Executing event +OPEN for class SYMULACJA, lib entry SYMULACJA Executing instruction at line 1 Executing object function +CREATE for class N_CST_CONST, lib entry N_CST_CONST Executing instruction at line 2 Executing object function +CREATE for class NONVISUALOBJECT, lib entry _TYPEDEF End object function +CREATE for class NONVISUALOBJECT, lib entry _TYPEDEF Executing instruction at line 3
|
|
|
|
Tracing database retrievals/updates/deletes and other db worklad using Native PowerBuilder drivers.
The native PowerBuilder database drivers (only in PB Enterprise version) has possibility to collect application activities that execute any statement at database site. If you noticed that the performance problem is caused by database operations then try to generate trace from database drivers. The log store information about every statement that is sent do database server and time the application has been waiting for results. The trace log besides statements also store data that has been requested from db server. Using the trace you can localize most time consuming operations, or data that are incorrectly retrieved many times. If you noticed that the same data are retrieved constantly by different business operations then the data is potentally the best to cache at client side.
To enable database trace enter ‘TRACE’ keyword in SQLCADBMS property :
SQLCA.DBMS = "TRACE O84 Oracle8/8i (8.x.4+)"
|
|
|
|
Attention!
To enable tracing and debugging functionality for epplications compiled to machine code, the executables have to be compiled with enable trace option.
|
|