RICHINMINN
Programmer
- Dec 31, 2001
- 138
Has anyone done any comparisons between the assortment of numeric data formats in COBOL? Yea, the ones like
- display numeric -- PIC 9(x)
- COMP -- PIC 9(x) COMP
- COMP SYNC -- PIC 9(x) COMP SYNC
- COMP-1 -- PIC 9(x) COMP-1
- COMP-2 -- PIC 9(x) COMP-2
- COMP-3 -- PIC 9(x) COMP-3
- COMP-4 -- PIC 9(x) COMP-4
- BINARY -- PIC 9(x) BINARY
- PACKED-DECIMAL -- PIC 9(x) PACKED-DECIMAL
I've done some testing with them, and the results have surprised some people around here.
I started out writing a simple COBOL program that performs a simple addition 1,000,000 times, with the number being added in one of the above 9 data formats, and the accumulator in one of the 9 data formats, as well. (Yes, that gives a total of 81 possible combinations, but my main interest was in the same-data-type combinations, such adding a packed-decimal integer to a packed-decimal accumulator, or a COMP-1 to a COMP-1.) I ran all the tests on the same system, as a DB/2 program so I could use the DB/2 time with its accuracy to 6 decimal places, rather than the regular system time with accuracy to 2 decimal places. (Note that each format's speed is relative to that of display numeric.)
The results:
DATA FORMAT E.T.(sec) Ops/Sec Speed (disp num=1)
----------- --------- ------- -------------
COMP-1 0.020814 48,044.585 3.033055
COMP-2 0.027581 36,256,843 2.288895
PACKED-DECIMAL 0.055864 17,900,616 1.130066
**display numeric 0.063130 15,840,329 1.000000 **
COMP-3 0.095595 10,460,798 0.660390
COMP 0.742182 1,347,378 0.085060
COMP-4 0.829014 1,206,252 0.076151
BINARY 0.846406 1,181,466 0.074586
COMP SYNC 0.876523 1.140,611 0.072007
Interesting, eh?
So when someone tells you to use binary values for all accumulators, you can tell them that plain ol' display numeric will perform the same calculations 14 as fast! (Well, 13.4073418604 times as fast...)
I've got similar test results for the other three primary arithmetic functions, and the results are pretty much in line with the above numbers. If anyone's interested, I can post those results as well.
Has anyone out there done any similar tests? I'd love to hear what other people have found.
Rich (in Minn.)
- display numeric -- PIC 9(x)
- COMP -- PIC 9(x) COMP
- COMP SYNC -- PIC 9(x) COMP SYNC
- COMP-1 -- PIC 9(x) COMP-1
- COMP-2 -- PIC 9(x) COMP-2
- COMP-3 -- PIC 9(x) COMP-3
- COMP-4 -- PIC 9(x) COMP-4
- BINARY -- PIC 9(x) BINARY
- PACKED-DECIMAL -- PIC 9(x) PACKED-DECIMAL
I've done some testing with them, and the results have surprised some people around here.
I started out writing a simple COBOL program that performs a simple addition 1,000,000 times, with the number being added in one of the above 9 data formats, and the accumulator in one of the 9 data formats, as well. (Yes, that gives a total of 81 possible combinations, but my main interest was in the same-data-type combinations, such adding a packed-decimal integer to a packed-decimal accumulator, or a COMP-1 to a COMP-1.) I ran all the tests on the same system, as a DB/2 program so I could use the DB/2 time with its accuracy to 6 decimal places, rather than the regular system time with accuracy to 2 decimal places. (Note that each format's speed is relative to that of display numeric.)
The results:
DATA FORMAT E.T.(sec) Ops/Sec Speed (disp num=1)
----------- --------- ------- -------------
COMP-1 0.020814 48,044.585 3.033055
COMP-2 0.027581 36,256,843 2.288895
PACKED-DECIMAL 0.055864 17,900,616 1.130066
**display numeric 0.063130 15,840,329 1.000000 **
COMP-3 0.095595 10,460,798 0.660390
COMP 0.742182 1,347,378 0.085060
COMP-4 0.829014 1,206,252 0.076151
BINARY 0.846406 1,181,466 0.074586
COMP SYNC 0.876523 1.140,611 0.072007
Interesting, eh?
So when someone tells you to use binary values for all accumulators, you can tell them that plain ol' display numeric will perform the same calculations 14 as fast! (Well, 13.4073418604 times as fast...)
I've got similar test results for the other three primary arithmetic functions, and the results are pretty much in line with the above numbers. If anyone's interested, I can post those results as well.
Has anyone out there done any similar tests? I'd love to hear what other people have found.
Rich (in Minn.)