Today I was troubleshooting the performance of calling a procedure (CallThis.p) in a loop that had an INPUT-OUTPUT dataset:
DEFINE INPUT-OUTPUT PARAMETER DATASET FOR DS_AsmBom.
I *always* call this procedure with "BY-REFERENCE" like so:
RUN app/Production/ReadBomHeader.p (
INPUT-OUTPUT DATASET DS_AsmBom BY-REFERENCE).
Given that I always call the procedure with a BY-REFERENCE dataset, it didn't seem important that the dataset declared in the called program, CallThis.p, was defined without using the additional keyword "REFERENCE-ONLY". IE. I assumed that the runtime would skip over the redundant dataset in CallThis.p. It isn't needed when another "BY-REFERENCE" dataset has been provided as a parameter.
However it turns out that there is a penalty that is paid by omitting REFERENCE-ONLY. It appears to be about a tenth of a millisecond on every call to the procedure. Perhaps the runtime is still allocating and disposing of the additional dataset . This is something to remember when calling a procedure numerous times with a "BY-REFERENCE" data parameter! You may want still want to modify the program that is being called - so that it never allocates its own data.