 |
| How to boost the performance of
my programs further? |  |
 |
 |
Any program is only as good as the one who runs it. This blanket
conclusion surely applies to tdbengine, too. So "good" also means
"fast".
There are some tricks with which help you can demand even the last pinch of speed from youre programs.
But please notice that often it makes sense to find a compromise between speed and stability. What is the fastest database good for if entries disappear regularly?
Using a clever combination of the tricks listed here you can fetch noticeable more of youre applicationes. 1. Set the Runtime switch "No Break"
At default tdbengine
checks repietedly in a second whether there is the
file called "abort" in the same directory which the executed .prg is
in. If it finds an ilk file it will immediately abort the execution of
the modul and try to delete the "abort" file.
It's
very handy if you have only limited access as a developer/system
administrator to the server which tdbengine runs on. So you can "kill"
an endless tdbengine easy with FTP. You have only to put an empty text
file called "abort" in the directory of the modul and the process will
end at once.
But if you anyway have a shell or root access to the executive server
you won't need this kind of external terminating of programs.
Therefore just set the runtime switch nb to 1, when youre main procedure starts.
Procedure Main SetPara("nb 1") ... //here is the start
Endproc
Depending on the program it can earn you up to 50 percent more
performance. (In a loop doing nothing but incrementing an integer
variable in my tests it caused 60% more performance.)
That's the source code I've tested it on and detected the speed:
Procedure Main SetPara("nb 1") cgiclosebuffer var x,y : integer = 0 var n : real = now while x++ < 100 do y := 0 while y++ < 300000 do end end cgiwriteln("t = "+TimeStr(Now - n,3))
Endproc
Notice: If you're sure that you don't need the abort file any more
you'll can switch the enquiry of it off directly in tdbengine.ini.
Thereto just set in [globals] or [ihrprg] nobreak=0. So you won't have to care manual of shifting the switch. 2. Optimating youre loops - brevity is the soul of wit
To increment control variables write X++ or X-- instead of X := X +1 or X := X -1 -it earns a lot of performance.
Furthermore pack as many in an order as you can.
For example this loop has to identify all entries till the first
empty element of the aLfd array (here =0). Thereto any element will
compared with 0. If the compairing returns TRUE the loop will be ended.
The control variable X contains the number of engaged elements.
x:=0
REPEAT
UNTIL ~aLfd[x++]
is noticeable faster then
x:=0
REPEAT x := x +1
UNTIL aLfd[x] = 0
The tilde ~ is short for NOT, it negates the result of the following expression.
|