Example

Program profiler example.

Source code

File: mymod.4gl
PUBLIC FUNCTION fA(s,n_a)
  DEFINE s STRING
  DEFINE n_a,i INTEGER
  FOR i=1 TO n_a
    DISPLAY "fA "||s||" n:"||i
  END FOR
END FUNCTION
File: myprog.4gl
IMPORT FGL mymod

MAIN
  DISPLAY "Profiler sample"
  CALL fB()
  CALL fC(2)
END MAIN

PRIVATE FUNCTION fB()
  CALL mymod.fA("fB",10)
  CALL fC(5)
END FUNCTION

PRIVATE FUNCTION fC(n_c)
  DEFINE n_c INTEGER
  WHILE n_c > 0
    CALL mymod.fA("fC",2)
    LET n_c=n_c-1
  END WHILE
END FUNCTION

Profiler output (stderr)

Flat profile (order by self) 
   count  %total  %child   %self  name
       8    90.5    42.9    47.6  mymod.fA
      72    30.5     0.0    30.5  <builtin>.rts_Concat
      25    10.1     0.0    10.1  <builtin>.rts_display
       2    58.9    54.6     4.4  myprog.fC
       8     3.1     0.0     3.1  <builtin>.rts_forInit
       1    99.3    97.2     2.0  myprog.main
       1    77.7    76.2     1.5  myprog.fB


Call graph (order by self)

index      %total   %self  %child  calls/of         name
           36.40   16.03   20.37      1/8        <-- myprog.fB
           51.31   24.42   26.89      7/8        <-- myprog.fC
[1]        87.71   40.45   47.26        8        *** mymod.fA
           28.07   28.07    0.00     72/72       --> <builtin>.rts_Concat
           16.22   16.22    0.00     24/25       --> <builtin>.rts_display
            2.97    2.97    0.00      8/8        --> <builtin>.rts_forInit
-------------------
           28.07   28.07    0.00     72/72       <-- mymod.fA
[2]        28.07   28.07    0.00        72       *** <builtin>.rts_Concat
-------------------
            1.67    1.67    0.00      1/25       <-- myprog.main
           16.22   16.22    0.00     24/25       <-- mymod.fA
[3]        17.89   17.89    0.00        25       *** <builtin>.rts_display
-------------------
           79.95    4.71   75.24      1/1        <-- myprog.main
[4]        79.95    4.71   75.24        1        *** myprog.fB
           38.84    2.07   36.77      1/2        --> myprog.fC
           36.40   16.03   20.37      1/8        --> mymod.fA
-------------------
           15.63    1.09   14.54      1/2        <-- myprog.main
           38.84    2.07   36.77      1/2        <-- myprog.fB
[5]        54.47    3.16   51.31        2        *** myprog.fC
           51.31   24.42   26.89      7/8        --> mymod.fA
-------------------
            2.97    2.97    0.00      8/8        <-- mymod.fA
[6]         2.97    2.97    0.00        8        *** <builtin>.rts_forInit
-------------------
           99.22    1.97   97.25      1/1        <-- <top>
[7]        99.22    1.97   97.25        1        *** myprog.main
           79.95    4.71   75.24      1/1        --> myprog.fB
           15.63    1.09   14.54      1/2        --> myprog.fC
            1.67    1.67    0.00      1/25       --> <builtin>.rts_display
-------------------