Profiler output: Flat profile

The flat profile shows a summary of the functions called during the program execution.

The flat profile contains a list of the functions called while the programs was running.

Tip:

Runtime system internal function names start with the rts_ prefix. For example, the rts_display() function implements the DISPLAY instruction. Showing these internal functions in the profiler output is useful to analyse the code. Usually rts_* functions appear at the top of the flat profile list, because most of the processing time is spend in these runtime functions (for example to execute SQL statements). To improve your code, spot the first user function that appears in the flat profile list, and check the %self number: This is where user code can be improved.

Table 1. Flat profile columns
Column Name Description
count Counts the number of calls for this function
%total Percentage of execution time spent in this function. Includes time spent in subroutines called from this function.
%child Percentage of execution time spent in functions called from this function.
%self Percentage of execution time spent in this function excluding the time spent in subroutines called from this function.
name Function name

100% represents the total processing time. The time spent waiting for user interaction is ignored.

Output example:

Flat profile (order by self)
   count  %total  %child   %self  name
      25    46.5     0.0    46.5  <builtin>.rts_display
      72    19.3     0.0    19.3  <builtin>.rts_Concat
       8    75.3    61.5    13.8  mymod.fA
       1    82.4    70.4    12.0  myprog.fB
       1   100.0    96.8     3.2  myprog.main
       2    28.6    26.0     2.6  myprog.fC
       8     2.6     0.0     2.6  <builtin>.rts_forInit

Description:

  • The lines are ordered by the percentage of time spent in the actual function code (%self column), in descending order, to show most time consuming functions first.
  • 46.5% of the time was spent in the rts_display function to ouput text to the terminal. Since this is a built-in function, there is no user code to improve here.
  • 19.3% of the time is spent in the rts_Concat built-in function. No improvement possible here.
  • 13.8% + 12.0% = 1/4 of the program execution time is spent in the mymod.fA and myprog.fB user defined functions. This is where improvements might be possible.