Array size and speed application

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Array size and speed application

#1 Post by Victorio »

Hi,
Why have negative effect to speed application used size of Array ?
In my program I have
DECLARE arow[20000000]

Then I use this arow to read lines from file in cycle
FOR i=1 to x
arow:=something...
NEXT

x can be 100000, 2.000.000 and so 20.000.000

If I declare to 2.000.000 program speed is about 3x speed then declare 20.000.000.

Can I set some dynamic declaration without set to fix number of array elements ?

Leon Berger
Posts: 36
Joined: Thu Jan 28, 2010 2:30 pm

Re: Array size and speed application

#2 Post by Leon Berger »

Victorio wrote:Hi,
Why have negative effect to speed application used size of Array ?
In my program I have
DECLARE arow[20000000]

Then I use this arow to read lines from file in cycle
FOR i=1 to x
arow:=something...
NEXT

x can be 100000, 2.000.000 and so 20.000.000

If I declare to 2.000.000 program speed is about 3x speed then declare 20.000.000.

Can I set some dynamic declaration without set to fix number of array elements ?


Yes, You can :-)

Code: Select all

arow := {}, cstring := ""

open file
do while not end of file
   cstring := read line
   aadd(arow, cstring)
enddo
close file
Best regards
Leon

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

Re: Array size and speed application

#3 Post by Victorio »

... aadd().. ok,

I tested it now, super !!! , time processing from 11 sec to 5sec.
I reprogramming old C++ utilities and always comparing time processing old C++ and alaska.
In this example time C++ utility is about 3sec, it is nearly alaska xbase result.

Thank you :clap:

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Array size and speed application

#4 Post by skiman »

Hi,

Maybe you can post your code. Perhaps it can be optimized to get even better results.
Best regards,

Chris.
www.aboservice.be

Post Reply