Investigate the overheads of function calls

Investigate the overheads of function calls

Author: Arthur Pool (see EMail Addresses)

(Statements in green color [like this] are comments from Bernd Schemmer)

(Use the included REXX program to run the test described in this text on your PC)

In the OS/2 operating system, there are several different ways a REXX program can call a function coded in REXX, each of which has implications for both performance and maintainability.

These options are discussed (briefly) in the WARP REXX on-line information (at least, in WARP Connect V3), which says (inter alia):

"... internal labels take first precedence, then built-in functions, and finally external functions. External functions and subroutines have a system-defined search order. REXX searches for external functions in the following order:

"

In practice then, the options, and their implications, are:

[1] Include the source code for the function in the primary source file. This should provide the best performance. However, if the function is to be called by more than one primary REXX program, this approach is undesirable in that it requires duplication of code, with consequent maintenance problems.

[2] Load the macro function into a REXX MacroSpace. This can be achieved using the RexxAddMacro call from C, or using the RxAddMacro function provided in the RXU utility package (I understand that WARP 4 (Merlin) provides a similar function in the REXXUTIL package but I have no experience with that; see New REXXUTIL functions in Object REXX, The functions to work on the macro space, and LoadMac.cmd for information about the REXXUTIL DLL included in Object REXX ). This approach is more or less equivalent to the EXECLOAD facility in VM/CMS. This approach should provide performance somewhere between the preceding and following approaches. It does however have some management costs:

As noted above, functions can be loaded in either of two ways:

However, it is worthwhile to consider the meaning of current extension and default extension. When a function is loaded into the MacroSpace, it can be loaded with an extension (eg, .CMD) or without an extension. In these tests, as the primary REXX file had an extension of .CMD, it appears that the current extension is .CMD. We therefore measured the performance of functions loaded into the MacroSpace (and called) with an extension of .CMD and also without an extension.

Note however that in general one would prefer to load functons without extension so that they are equally accessible to REXX programs with any extension - whether called from REXX command files (.CMD), THE macros (.THE), or from other environments. It's also cumbersome to have to specify the extension when invoking the macro.

We measured 4 sub-cases:

Following are some measurements of elapsed time (in seconds) for 255 function calls using these various approaches (use the included test program to run this tests on your PC).

 [C:\Usr\AFP\SW\Testing]REXX_Function_Call_Performance 255

 [1]                             function in the source program:      0.88
 [2a]            MacroSpace function, pre-order, .CMD extension:      2.06
 [2b]              MacroSpace function, pre-order, no extension:      2.13
 [2c]           MacroSpace function, post-order, .CMD extension:     91.09
 [2d]             MacroSpace function, post-order, no extension:    180.87
 [3a]   function in an external source file - CURRENT directory:     10.28
 [3b]       function in an external source file - START of PATH:     12.66
 [3c]         function in an external source file - END of PATH:     55.25
 [3d] function in an external source file - END of PATH, no EAs:     42.12

[C:\Usr\AFP\SW\Testing]

Notes:

1) The function used was:

 
      REXX_Function_Call_Performance_1:
        return arg(1)**arg(1)

2) These measurements were on a 80486-DX4 with OS/2 Warp Connect (Blue Box) with no service applied, using (obviously) HPFS.

(Results on a P133 with 32 MB RAM and OS/2 WARP 4 with Fixpack #7 and Object REXX with HPFS:

 
D:\...\DEVELOP\REXX\FWTOOLS\REXXTT\Test>REXX_Function_Call_Performance 255

 [1]                             function in the source program:      0.15
 [2a]            MacroSpace function, pre-order, .CMD extension:      0.48
 [2b]              MacroSpace function, pre-order, no extension:      0.49
 [2c]           MacroSpace function, post-order, .CMD extension:      4.70
 [2d]             MacroSpace function, post-order, no extension:     11.77
 [3a]   function in an external source file - CURRENT directory:      2.12
 [3b]       function in an external source file - START of PATH:      2.53
 [3c]         function in an external source file - END of PATH:      5.82
 [3d] function in an external source file - END of PATH, no EAs:      7.75

)

(Results on a P266 with 160 MB RAM and OS/2 WARP 4 with Fixpack #12 and Object REXX with HPFS:

 

D:\...\DEVELOP\REXX\FWTOOLS\REXXTT\Test>REXX_Function_Call_Performance.CMD 255

 [1]                             function in the source program:      0.04
 [2a]            MacroSpace function, pre-order, .CMD extension:      0.17
 [2b]              MacroSpace function, pre-order, no extension:      0.17
 [2c]           MacroSpace function, post-order, .CMD extension:      2.46
 [2d]             MacroSpace function, post-order, no extension:      6.61
 [3a]   function in an external source file - CURRENT directory:      0.81
 [3b]       function in an external source file - START of PATH:      1.08
 [3c]         function in an external source file - END of PATH:      2.98
 [3d] function in an external source file - END of PATH, no EAs:      3.46

)

Conclusions:

History:


[Back: Using the REXX Macro Space]
[Next: Test program to test the overheads of function calls]