Performance: tuning COBOL

Profile first

Measure before tuning. Time the run, find the paragraph that dominates, and fix that one. Most COBOL bottlenecks are file I/O or a nested loop, not the arithmetic.

USAGE choices

Move hot counters and sums to USAGE COMP or COMP-4 (binary) so the CPU adds them directly instead of converting text. Keep money in COMP-3 for exact decimals, and leave DISPLAY for the outer layer where humans read it.

I/O patterns

Read files once, not once per lookup: load small reference tables into working storage, or sort both inputs by the same key and merge them in one pass. Let the SORT verb do the ordering instead of hand-written sorts, and keep WRITE buffers full by writing records in batches where the file allows it.

Article author: Arthur Isaev