Comp-3 = Packed-Decimal is faster, because the z/Architecture, and also previous architectureres beginning with S/360, has built in instructions to directly manipulate Packed-Decimal data, e.g AP (Add packed). For other numeric formats, the compiler has to generate code to manipulate the numeric variable in different ways.
Have a look at this sample program:
000010 cbl list
000100 Identification Division.
000200 Program-Id. PACKED.
000210 Data Division.
000300 Working-Storage Section.
000400 77 Ws-PackedS Pic S9(07) Packed-Decimal Value 0.
000410 77 Ws-Packed Pic 9(07) Packed-Decimal Value 0.
000500 77 Ws-BinaryS Pic S9(07) Binary Value 0.
000510 77 Ws-Binary Pic 9(07) Binary Value 0.
000600
000700 Procedure Division.
000800 Add 1 to Ws-PackedS
000810 Add 1 to Ws-Packed
000900 Add 1 to Ws-BinaryS
000910 Add 1 to Ws-Binary
001000 GoBack
001100 .
This is the code that is generated by the compiler:
000011 *
000011 ADD
000334 FA30 8000 A02E AP 0(4,8),46(1,10) WS-PACKEDS
00033A F833 8000 8000 ZAP 0(4,8),0(4,8) WS-PACKEDS
000012 ADD
000340 D203 D100 8008 MVC 256(4,13),8(8) TS2=0
000346 960F D103 OI 259(13),X'0F' TS2=3
00034A FA30 D100 A02E AP 256(4,13),46(1,10) TS2=0
000350 D203 8008 D100 MVC 8(4,8),256(13) WS-PACKED
000356 960F 800B OI 11(8),X'0F' WS-PACKED+3
000013 ADD
00035A 4830 A012 LH 3,18(0,10) PGMLIT AT +10
00035E 5A30 8010 A 3,16(0,8) WS-BINARYS
000362 1823 LR 2,3
000364 8E20 0020 SRDA 2,32(0)
000368 5D20 C000 D 2,0(0,12) SYSLIT AT +0
00036C 5020 8010 ST 2,16(0,8) WS-BINARYS
000014 ADD
000370 4830 A012 LH 3,18(0,10) PGMLIT AT +10
000374 5A30 8018 A 3,24(0,8) WS-BINARY
000378 1823 LR 2,3
00037A 8E20 0020 SRDA 2,32(0)
00037E 5D20 C000 D 2,0(0,12) SYSLIT AT +0
000382 5020 8018 ST 2,24(0,8) WS-BINARY
000015 GOBACK
Even if you are not an assembler specialist, you can easily tell that the the first add generates fewer HW-instructions to do the same task, not to say that fewer always is faster, it depends on the format of the instructions. Pls also observe that if you specify the numeric variable without a sign, there is more code.
The best choice is Packed-Decimal (COMP-3) and a Sign (S9).
Regarding space Packed-Decimal is more effective, as the data is stored as decimal data, one decimal digit in one half byte, as Binary uses one byte oer digit.