Speed test Tdatabase vs. dbase style

Speed test Tdatabase vs. dbase style

Postby Otto » Tue Dec 11, 2012 8: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: Select all  Expand view
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()} )    
Last edited by Otto on Fri Dec 28, 2012 8:06 am, edited 1 time in total.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6064
Joined: Fri Oct 07, 2005 7:07 pm

Re: Seed test Tdatabase vs. dbase style

Postby Gale FORd » Tue Dec 11, 2012 8: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.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Seed test Tdatabase vs. dbase style

Postby Otto » Tue Dec 11, 2012 9:00 pm

Hello Gale,
I made the test inside an existing program where I use:
Code: Select all  Expand view
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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6064
Joined: Fri Oct 07, 2005 7:07 pm

Re: Seed test Tdatabase vs. dbase style

Postby James Bott » Sun Dec 23, 2012 1: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 44 guests