Tips for cobol performance tuning

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: Tips for cobol performance tuning

Postby steve-myers » Sat Sep 14, 2019 6:01 am

sergeyken wrote:Both odd-, and even-number of digits Packed decimals:
1) use the same space in memory,
2) use the same machine instructions for ANY calculation

The only difference is, even-number digits is stored in the same field in memory, but one extra decimal 0-digits is added in the unused half-byte.

There is absolutely no reason to make any performance difference.

Furthermore, performance difference related to CPU operations, if any, can affect 0.0000000001% to 0.1% of overall performance issues, caused mainly by senseless algorithmic approach, and/or by wrong organization or required I/O operations.

I agree with sergeyken about the relative performance in doing arithmetic. However, there may be performance advantages converting an odd number of digits to printable decimal digits than doing the same conversion with an even number of decimal digits. Converting an odd number of digits, the program can move an ED instruction pattern to the output area and then use the ED instruction directly. Converting an even number of digits the program most likely copies the master ED pattern to a work area, just as before, executes the ED instruction, tests the result area to see if it effectively overflowed the output area, and then moves the low order even digits to the output area. Look at the Assembler code.
* Odd digits (best case)
         ED    OUTAREA,PDNUM
* Odd digits (worse case)
         ED    WKAREA(L'

* Even digits
         ED    WKAREA(L'
         BE    NUMOK
         ...   Overflow code here
OUTAREA  DS    CL4  or CL5  or CL6, for odd digits
EDPATT   DC    0C' 12345',C' ',X'2020202120'
PDNUM    DC    P'12345'

The worse case odd digits may also have overflow issues, though it is less likely.

I grant my sample code is over simplified, but it does point out the possible issues.
Global moderator
Posts: 2086
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 235 times


Return to IBM Cobol


  • Related topics
    Last post