C language and Xbase

Xbase++ 2.0 Build 554 or later
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: C language and Xbase

#11 Post by rdonnay »

C++ code : 6 seconds
Alaska code first example without optimalization byte to byte read from file : 3minutes and 13 seconds
Alaska code optimalized full file read to variable string and so write variable to file once: 18 seconds :violin:
I would consider this a success.
Alaska code that is only 3 times slower than C code is remarkable.
This is one of the things I like about Xbase++.
There is a lot of processing going on when building and processing a large eXpress++ GetList.
Performance is a key factor to a successful SGL architecture and is why eXpress++ can do the job.
The eXpress train is coming - and it has more cars.

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: C language and Xbase

#12 Post by Victorio »

ok, thanks all for tips and help.
now I must reprogramming every utilities in C++ and implement it to main application with Gui.
After it I will see how program work.
I like Ca Clipper also for his power in comparing with FoxPro.
Now I like Xbase too :)
I am sure , that Alaska Xbase and eXpress is performance tool with many many options, but I now only discovering what can do with this tool.
Before one year I do not know how make "Hello word" with it.

Victorio

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: C language and Xbase

#13 Post by rdonnay »

Before one year I do not know how make "Hello word" with it.

Code: Select all

#include "dcdialog.ch"

FUNCTION Main()

LOCAL GetList[0]

@ 0,0 DCSAY 'Hello World!" SAYSIZE 0 FONT '24.Arial Bold'

DCREAD GUI TITLE 'Hello' FIT

RETURN nil
The eXpress train is coming - and it has more cars.

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: C language and Xbase

#14 Post by Victorio »

OK :D I bought Alaska Xbase and eXpress in december 2014 ... and first running exe was my holiday :P

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: C language and Xbase

#15 Post by rdonnay »

OK :D I bought Alaska Xbase and eXpress in december 2014 ... and first running exe was my holiday :P
Victorio -

I know that you are an eXpress++ user.
I posted the Hello World sample for those who have still not got started with Xbase++.

Roger
The eXpress train is coming - and it has more cars.

User avatar
TWolfe
Posts: 60
Joined: Thu Jan 28, 2010 7:34 am

Re: C language and Xbase

#16 Post by TWolfe »

Code: Select all

for j=0 to pomznak-1
.
.
next
It appears that 'j' is just a counter. Try:

Code: Select all

for j:=1 to pomznak
.
.
next


If this code is executed a million times or so it may save you another second depending on your machine speed.

HTH,
Terry
Last edited by TWolfe on Tue Oct 27, 2015 9:15 pm, edited 1 time in total.

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: C language and Xbase

#17 Post by Victorio »

Hi Terry,

Super, one mathematical operation (-1) spare save another 5 seconds :)
Thanks.

Now comparing :
C++code : 6 seconds
Alaska befor change (for j=0 to pomznak-1) : 17 seconds
Alaska after change (for j=1 to pomznak) : 12 seconds

here Xbase is only 2x slower than C.

It is important for me, because I need process about 150GB, then time of one from process will be now 40 hours.

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: C language and Xbase

#18 Post by rdonnay »

Alaska after change (for j=1 to pomznak) : 12 seconds
Make sure that j and pomznak are both LOCAL variables.
The eXpress train is coming - and it has more cars.

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: C language and Xbase

#19 Post by Victorio »

yes, both are local
...
Local j, pomznak
...

User avatar
TWolfe
Posts: 60
Joined: Thu Jan 28, 2010 7:34 am

Re: C language and Xbase

#20 Post by TWolfe »

A couple of more ideas --

Your Code:

Code: Select all

cBuffer=chr(znak)
* zápis znaku do výstupného retazca
cTargetString := cTargetstring+cBuffer
Note: I changed
YOUR -> cTargetString=cTargetstring+cBuffer
TO -> cTargetString := cTargetstring+cBuffer

The ":=" assignment operator is preferred over the ambiguous "=" operator. (The "=" operator can be assignment or comparison depending on context, try to save it for comparisons only. This will save you some nasty debug work in the future.)

Try:

Code: Select all

// cBuffer=chr(znak)  <- this is a wasted step
* zápis znaku do výstupného retazca
cTargetString += chr(znak)  // <- This saves a duplication of the string in memory
Also note that both the "J:=1 TO pomznak" and "cTargetString += chr(znak)" lines appear twice in your code snip, (change in both places).

This may help,
Terry
Last edited by TWolfe on Wed Oct 28, 2015 1:03 pm, edited 1 time in total.

Post Reply