jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Thu Jun 02, 2011 9:44 am Post subject: Passing control to an external routine in REXX |
|
|
I am posting this finding that I came upon the other day in the hope that it will help other developers. I invite the moderator or other experts to reply.
I have written a lot of REXX subroutines in order to re-use code that is common in different programs. Most of the programs I have written are not compiled.
I was running a program I had written to add a column of numbers, about 20000 records total. I found that if I was adding the numbers and didn't call a certain subroutine, the REXX program returned the results in about a second. However, if I called the subroutine, the program would take over a minute to add a similar number of records.
Using the time elapsed function, TIME("E"), I found that calling an external subroutine, even if no logic was being executed took about .02 seconds to execute. (I coded the subroutine to EXIT immediately after being called).
While .02 seconds doesn't seem like a lot of time, when you are executing the same command against 20000 records, it really adds up. I took the logic out of the subroutine and moved it into the main program, re-ran, and it took about a second to add the numbers.
My advice would be not to code commonly executed subroutines to be called from a main program, but to always put all your code in the main program. (I don't know if the same holds true for REXX programs which are compiled.)
REXX experts, care to discuss? |
|
kolusu Site Admin
![Site Admin Site Admin](images/ranks/adminpic.jpg)
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
|
Posted: Thu Jun 02, 2011 11:00 am Post subject: |
|
|
jim haire,
The poor performance of using subroutines is attributed to the search order of the subroutines. Internal labels take first precedence, then built-in functions, and finally external functions/subroutines. Interpreted REXX execs are not an ideal candidates for high volume processing.
You might want to read this
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ4A390/12.3
Kolusu |
|