Page 1 of 1

Array size and speed application

Posted: Tue Nov 24, 2015 3:32 am
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 ?

Re: Array size and speed application

Posted: Tue Nov 24, 2015 4:00 am
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

Re: Array size and speed application

Posted: Tue Nov 24, 2015 4:16 am
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:

Re: Array size and speed application

Posted: Wed Nov 25, 2015 1:22 am
by skiman
Hi,

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