Example

Program profiler example.

Sample program

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

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

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

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

Running the profiler

Flat profile (order by self) 
   count  %total  %child   %self name
       25    88.0     0.0    88.0  rts_display
       72     6.3     0.0     6.3  rts_Concat
        8    85.4    82.0     3.4  fa
        2    25.8    24.5     1.3  fc
        8     0.3     0.0     0.3  rts_forInit
        1    85.6    85.4     0.2  fb
        1    99.9    99.6     0.3  main 


Call graph (order by self)

index	  %total  %self  %child  calls/of	 name
 	   12.69   12.69    0.00      1/25       <-- main
 	   75.29   75.29    0.00     24/25       <-- fa
[1]	   87.98   87.98    0.00        25       *** rts_display
-------------------
	    6.35    6.35    0.00     72/72       <-- fa
[2]	    6.35    6.35    0.00        72       *** rts_Concat
-------------------
	   60.90    2.02   58.88      1/8        <-- fb
 	   24.51    1.43   23.08      7/8        <-- fc
[3]	   85.41    3.45   81.96        8        *** fa
 	   75.29   75.29    0.00     24/25       --> rts_display
 	    6.35    6.35    0.00     72/72       --> rts_Concat
 	    0.33    0.33    0.00      8/8        --> rts_forInit
-------------------
	    1.29    0.10    1.18      1/2        <-- main
 	   24.51    1.18   23.33      1/2        <-- fb
[4]	   25.80    1.29   24.51        2        *** fc
 	   24.51    1.43   23.08      7/8        --> fa
-------------------
	    0.33    0.33    0.00      8/8        <-- fa
[5]	    0.33    0.33    0.00        8        *** rts_forInit
-------------------
	   85.61    0.20   85.41      1/1        <-- main
[6]	   85.61    0.20   85.41        1        *** fb
 	   24.51    1.18   23.33      1/2        --> fc
 	   60.90    2.02   58.88      1/8        --> fa
-------------------
	   99.94    0.35   99.59      1/1        <-- <top>
[7]	   99.94    0.35   99.59        1        *** main
 	    1.29    0.10    1.18      1/2        --> fc
 	   85.61    0.20   85.41      1/1        --> fb
 	   12.69   12.69    0.00      1/25       --> rts_display
-------------------