Page 1 of 1

replacement of INITIALIZE verb

PostPosted: Thu Mar 12, 2020 4:45 pm
by arya_starc
Hi Team,

I am planning to replace INITIALIZE syntax in my cobol programs with normal MOVE statements. I am doing this for getting the better efficiency and utilization of cpu for my batch programs.

Is anyone doing this earlier and get better results in terms of optimization?
Please share your thoughts.

Thanks in advance.

Re: replacement of INITIALIZE verb

PostPosted: Thu Mar 12, 2020 5:16 pm
by NicC
What has this to do with system programming (where the topic was originally posted)? Moved.

What have your initial tests shown?

Re: replacement of INITIALIZE verb

PostPosted: Thu Mar 12, 2020 6:52 pm
by Robert Sample
What kind of variables do you have INITIALIZE on? If you are using INITIALIZE for elementary variables, you will see no improvement in CPU time or efficiency -- for elementary items, MOVE and INITIALIZE work exactly the same. For group variables, you may -- or may not -- see any improvement in CPU time and efficiency since such improvements would depend upon a number of factors. The only way to know for sure that there is an improvement to actually make the change and review the results.

I have seen major improvements in going from INITIALIZE to MOVE -- but the specific situation was the INITIALIZE was for a million-byte table (99 occurrences of 9,999 bytes) where the MOVE was only used to clear the 15 occurrences actually being used. And the INITIALIZE / MOVE statements were being executed about 2 million times per program execution. YMMV.

Re: replacement of INITIALIZE verb

PostPosted: Thu Mar 12, 2020 7:42 pm
by Terry Heinze
The only time I'm reluctant to use INITIALIZE is when a group item consists of many elementary items AND the group item needs reinitializing many times during the program. In that case, I initialize a group item once at the beginning of the program and save it. When the other group item needs reinitializing, I move the saved group to the group needing reinitializing (one big group move).

Re: replacement of INITIALIZE verb

PostPosted: Sat Mar 14, 2020 11:25 am
by chaat
if you are initializing arrays, I would strongly recommend that you modify the code such as to not require initialization of the entire array.

instead, keep track of how many elements of the array are being used and only initialize occurrences as they are used. This requires the use of hand coded searches or an OCCURS DEPENDING ON clause when declaring the array.

Note, that a hand coded binary search with a single key field is much more efficient than the SEARCH ALL verb. This is especially true with COBOL 6.

Chuck Haatvedt