Miscellaneous
Here are a number of points not covered elsewhere. The first two may make
considerable difference in performance depending on the particular code section,
the remainder are unlikely to have more than slight effect but are good
programming practise.
- Move loop independent code out of loops. Calculate the loop limits as
integers before the loop rather than in the loop control statements. (Use
INT if limits not integer. If limit is
INPUT, it will be a string, so do an arithmetic
operation on it to make it into a number. Unscaled integers are most efficient
as loop limits.)
- Ensure that idle loops do not waste system resources looking for work that
is not there. If a program loops looking for work and does not find any, it
should SLEEP or RQM
for a suitable period before trying again.
- When INPUTing responses that are not used
again once acted upon, re-use the same variable for input of similar
responses.
- For terminal output, use CRT instead of
PRINT which has to check which output device to
use.
- In multi-way logic, use
CASE instead of a series of
IF statements.
- In a CASE construct, order the
CASE statements with the most
likely outcome first.
- Use DataBasic format strings rather than
OCONV or
ICONV functions.
Cosmetic Performance
In an interactive application, the user is more concerned
with the perceived performance seen on the terminal rather than the actual
performance of the system. While something is changing on the terminal screen,
the system is perceived to be doing something, although what is being seen may
just be buffered output with the system actually idle for this user.
- If a program contains CPU intensive processing as well as large amounts of
terminal output, put the CPU intensive code immediately after the terminal
output. Some of the time taken for the CPU intensive processing is then hidden
from the user by the buffered output and by the time required to read the screen
and react.
- If processing of a terminal response may take more than a few seconds, consider
displaying a progress indicator. This concept is exemplified by the asterisks
output by the compiler and assembler, and by the C option of English
selects.