FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Speed test Tdatabase vs. dbase style
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Speed test Tdatabase vs. dbase style
Posted: Tue Dec 11, 2012 08:11 PM
One should always evaluate where to take Tdatabase and where not.
Look how much speed you loose with Tdatabase for such simple tasks.
Best regards,
Otto

11.12.2012 20:29:18: Start TDATA 73758.55
11.12.2012 20:29:18: Ende TDATA 73758.61

11.12.2012 20:29:18: Start dbase 73758.63
11.12.2012 20:29:18: Start dbaxe 73758.63

11.12.2012 20:31:20: Start TDATA 73880.46
11.12.2012 20:31:20: Ende TDATA 73880.53

11.12.2012 20:31:20: Start dbase 73880.54
11.12.2012 20:31:20: Start dbaxe 73880.54



Code (fw): Select all Collapse
logfile("speed.txt", {"Start TDATA", seconds() } )
oSetup := TData():New(,".\data\setup")
oSetup:use()

do while .NOT. oSetup:Eof()
   aadd( Setup():aRgEndText, Alltrim(oSetup:rgEnde1) + " " + (oSetup:rgEnde2) )
   oSetup:skip(+1)
enddo
oSetup:end()
logfile("speed.txt", {"Ende TDATA", seconds() } )

logfile("speed.txt", { "Start dbase", seconds() } )
use (".\data\setup") new
do while .NOT. Eof()
   aadd( Setup():aRgEndText, Alltrim( setup->rgEnde1) + " " + ( setup->rgEnde2 ) )
   skip
enddo
use
logfile("speed.txt", { "Start dbaxe", seconds()} )
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Seed test Tdatabase vs. dbase style
Posted: Tue Dec 11, 2012 08:47 PM

I noticed that your second test opens the data file in exclusive mode. I thing the tDatabase classes opens the data file in shared mode. It always runs slower in shared mode.

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Seed test Tdatabase vs. dbase style
Posted: Tue Dec 11, 2012 09:00 PM
Hello Gale,
I made the test inside an existing program where I use:
Code (fw): Select all Collapse
INIT PROCEDURE PrgInit

   SET CENTURY ON
   SET EPOCH TO YEAR(DATE())-98

   SET DELETED ON
   SET EXCLUSIVE OFF

   REQUEST HB_Lang_DE
   REQUEST HB_CODEPAGE_DEWIN

   HB_LangSelect("DE")
   HB_SetCodePage("DEWIN")

   SET DATE TO GERMAN

   SetHandleCount(205)
   rddsetdefault( "DBFCDX" )
   SetGetColorFocus()


   EXTERN DESCEND


RETURN


Best regards,
Otto
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Seed test Tdatabase vs. dbase style
Posted: Sun Dec 23, 2012 01:32 AM

Otto,

The speed is slower with the database object mainly because the object is loading the buffer array with all the fields. It is also checking for the BOF or EOF. If you set lBuffer:=.f. it will be faster. See database.prg - the skip() method.

The database class will always be slightly slower, but not much. Your example is only showing it to be 6 hundredths of one second slower. A user will never notice this.

There are so many advantages to be gained by using the database object, that tiny slowdowns are acceptable--at least I have never come across any significant speed issues. I have on occasion set lBuffer:=.f. while skipping in large loops when I didn't need the buffer loaded. In your example you could do the same.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion