Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

optimizing code

Status
Not open for further replies.

SM777

Technical User
Mar 7, 2001
208
GB
Does anyone have any tips for optimizing code to make things run slicker. I'm already doing the following:

Ramdrives for indexes and temporary files

Creating separate fields filled with dtos(date) rather than index on dtos(date) ....

Anyone got any other tips?
 
What I try to do is make sure there are no unsed variables anywhere in the program. Also, if variables only have their values used in part of a function, reuse them to cut down on the memory requirement of the variable table. And remember to release static and provate variables when you are finished with them.

I hope this helps.
 
First of all check all your do loops. If there is code which is doing the something unnecessary, lop it off. eg.
For a screen form, many people put the @ row, col, say within the loop. This is unnecessary and can be moved out of and just before the start of the loop.

Variables should be declared with the minimum scope and lifetime so that the memory allocated to them is recovered as soon as their purpose is over. Declare variables as local as far as is practicable.

For fine tuning your programs, you could put the time() function at the start and after the end of major chunks, like do loops of your programs. This will let you know how long each section of your program takes. You can then critically examine each section of the program which takes the longest time (given the set of databases being used) and then try to optimise them one by one.

All the best.

Subra if you find this useful let me know at vksubra@usa.net
 
A few thoughts to add to the other good advice...

Set a FILTER before building any temporary index
or before starting a DO WHILE LOOP that examines
and processes records based on certain content.

For lengthy file browsing (scrolling on screen) it
can be much faster to actually copy the
whole datafile from the server to the workstation
and then manipulate the browsing routines via the
local hard drive. (depends on the number of records)

Use the MEMORY() function before and after suspected
slow parts of your application and eliminate any
memory low problems in your code (usually variables
no longer required).

If you must set up blank variables in advance of a
sub-routine, then set each blank variable to ""
rather than the maximum length of characters they may contain on return.

Print reports to disk and then SPOOL them to the printer
of your choice. After the initial delay while the report
is built, the actual printout happens as fast as the
printer can handle it. (You won't get garbage in the
middle of the printout [caused by corruption from other jobs beating the spooler timeout setting] either!)

LINK your modules so that the most frequently required
code is all in the same internal overlay.
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top