Deutsch English
About tdbengine
Basic Course
Function reference
Bug Reporting
Support request
Home    Overview    Search    Impressum    Contact    Members
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.

  SetPara("nb 1")
  ... //here is the start

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:

    SetPara("nb 1")
    VAR x,y : INTEGER = 0
    VAR n    : REAL = Now
    WHILE x++ < 100 DO
        y := 0
        WHILE y++ < 300000 DO END
    CGIWriteLn("t = "+TimeStr(Now - n,3))

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.

UNTIL ~aLfd[x++]

is noticeable faster then

    x := x +1
UNTIL aLfd[x] = 0

The tilde ~ is short for NOT, it negates the result of the following expression.

See also:

tdbengine Anwendungen im Web:

Open-Source Web CMS

Open-Source Bug-Tracking

Free wiki hosting

Open-Source Wiki-System

Kostenloses Foren-Hosting

Dišt mit tdbengine 8-)

tdbengine chat

   Copyright © 2003-2004 tdb Software Service GmbH
   Alle rechte vorbehalten. / All rights reserved
   Last changed: 04.05.2004
{Fehler für :execmacro{execmacro="sessionspy"}

Programmers Heaven - Where programmers go!