HP RPG/XL Programmer's Guide (30318-90001)

9- 4
items that are searched with about the same frequency, place the
items in the table in either ascending or descending sequence and
perform a binary search (column 34 in the Header Specification is B).
Correctly placing items in a table and selecting the right search
method reduces the average time to find an item.
* Minimize the number and length of table entries. This reduces the
size of the run-time data segments.
* Get rid of indicators that are not used. They cause warnings to be
printed during compilation.
* If a file has only one input record type defined, do not condition
Calculation Specification operations with its associated indicator.
* Wherever possible, use subroutines (EXSR) to avoid duplicate code.
The execution of subroutines can be conditioned by indicators. Use
external subroutines for operations that can be handled more
efficiently in other languages (for example, string manipulation).
Output Specifications
* Put the most frequently used Output Specifications first.
* When conditioning output, place the most frequently used indicator
first in the OR lines.
* Use record lengths that match the number of characters actually
written. For example, if a report requires only 60 characters, enter
60 as the record length rather than 132 (maximum length).
* If terminal output ($STDLST) includes long and short messages, define
a file for each type. Terminal output records are padded with blanks
before being displayed. Longer record lengths require more memory
and transmission time.
Improving Input/Output Performance
You can decrease the time it takes to process disc files by observing a
few simple guidelines. These relate to the physical placement of files
on disc and their blocking factors. The next four sections discuss the
efficiencies to employ whenever you're working with disc files. (Refer
to operating system manuals, such as
Accessing Files Programmer's Guide
,
for more information on the disc files used with RPG.)
MPE Files
MPE files are sequential and random files. They are not KSAM files or
TurboIMAGE databases. When you use MPE files, follow these guidelines:
* Use block lengths that are multiples of 256 bytes.
This ensures efficient use of input/output buffers.
* If the file is processed sequentially, make the block length as large
as possible.
This reduces the number of physical reads to the disc. Since disc
I/O is the primary factor in throughput, choose the block length
carefully. For example, you might enter a record length of 80 bytes
and a block length of 32 records as follows:
:BUILD DFILE;REC=-80,32,F,ASCII;DISC=24000
A block length of 32 records requires 750 disc accesses to process
the entire file of 24,000 records. A block length of 3 requires
8,000 disc accesses.
* Use address-out sorts when available disc space is limited.
Address-out sorts produce output files containing 4-byte record
addresses. You use these record addresses to retrieve data records
in sorted order.
The RPG utility, XSORT, can be used to create address-out (ADDROUT)
files (for detailed information on XSORT, see the
RPG Utilities