Using PowerBuilder Code Profiling in a Real-life Application

Code profiling is crucial for optimizing application performance, identifying bottlenecks, and enhancing efficiency. It enables targeted improvements, ensuring optimal resource utilization and a smooth user experience.

This tutorial describes how to enable performance tracing and identify the code that needs to be tuned to improve the overall performance of a PowerBuilder application.

How to Use Code Profiling for PowerBuilder Apps in Visual Expert?

  • Open your application in the PB IDE.
  • Add the veperfmanager.pbl file. It contains the functionality to extract performance analysis for executed functions or events.

    Location of veperfmanager.pbl 
    C:\Program Files\Novalys\Visual Expert 2023\PowerBuilderPerformance

     
  • Once the VEPerfManager PBL is added to the application, enter the following code in the application startup to record performance data. 
          //Start Tracing 
          vepbtracemanager veperfmang
          veperfmang = create vepbtracemanager
          veperfmang.starttrace("VEPB.INI") 
    

    For Example:
    Start Tracing PowerBuilder Code Performance

  • Enter the below code when closing the application to stop tracing performance data. The *.vepbperf file will be generated containing the performance data of that session
          //Stop Tracing 
          vepbtracemanager veperfmang 
          veperfmang = create vepbtracemanager
          veperfmang.endtrace("VEPB.INI") 
      

    For Example:
    End Tracing PowerBuilder Code Performance

    StartTrace and EndTrace methods use the VEPB.INI file as input.
    VEPB.INI file Input for Performance Analysis

    This file contains the default configurations required to create the output file along with the parameters to be measured. (See below)

    1. FunctionOrEventTime=
      This field allows you to decide whether to include the functions and events in the performance analysis by VE. The field value can be either 1 or 0 respectively.
      For instance:
      FunctionTime=1 → indicates to include functions
      EventTime=1 → indicates to include events
      FunctionOrEventTime=1 → indicates to include both functions and events
      ActiveLog=1 → provides more information when a user faces difficulties using the PB Performance functionality
      ActiveLine=1 → provides timing information for each line of code
    2. OutputDirectory=
      This field sets the output directory path for the performance file(*.vepbperf). By default, it will use the folder containing the PB target.
      Output Directory Path for PB Performance File
  • On closing the application, the .vepbperf file is generated as shown above.
  • Now run Visual Expert and activate the beta feature tab as shown below.
    Right-click on the ribbon bar and select [Customize Ribbon].
    Customize Visual Expert Ribbon
  • In the Ribbon customization window, select the [Beta Features] tab and click [OK].
    Ribbon Customization Window
    You will now be able to see the Beta Feature tab in the Ribbon menu.
    Beta Features Tab Activated
  • Locate the [Open PB Performance File] button under the Beta Features tab. Click on the button to initiate the file navigation dialog.
    Browse to the location of the generated VEPBPERF file and open it.
    Open PowerBuilder Performance File
  • Visual Expert will process the performance file and populate the resultant TreeView from the data.
    Process PowerBuilder Performance File
▪ Select an item in the TreeView to see the related profiling information in the source code view.
Display Populated Data in TreeView
▪ In the source code view, you will see the details below along with the percentage and number of occurrences of the code.
Display Populated Data in Source Code

Note: The percentage indicates the % amount of time taken by that line to execute.
For example, if a method takes 10 minutes to execute and one line of code within that method takes 7 minutes to execute, that line is responsible for 70% of the total time it takes for the method to run.

  • Use the navigation panel macro to explore the tree further by expanding nodes.
    You can view all children and their items, to get a more comprehensive understanding of the performance analysis results.
    Performance Profiling

Know more about Visual Expert Performance Analysis for PowerBuilder Apps