Making Revolution faster with really big arrays
Wouter
wouter.abraham at scarlet.be
Fri Apr 29 06:07:22 EDT 2005
On 28 Apr 2005, at 17:59, Dennis Brown wrote:
> Frank,
>
> This is a simplified algorithm that I think would best translate
> directly between Transcript and PostgreSQL for a time trial. Just
> make sure the PostgreSQL code is an item by item algorithm also.
>
> Thanks,
> Dennis
>
> Transcript output on my machine: 1,000,000 Element Sum = 500500000
> Elapsed Time = 11.467659 seconds.
>
> on mouseUp
> global gTestArray
> if number of lines of the keys of gTestArray is not 1000000 then
> --already done the init
> put empty into gTestArray --start with an empty a variable
> repeat with x = 1 to 1000
> repeat with y = 1 to 1000
> put x into gTestArray[x,y]
> end repeat
> end repeat
> end if
> --
> put the long seconds into st
> Method6
> get the long seconds
> put " Elapsed Time ="&&(it - st)&&"seconds." after msg
> end mouseUp
>
> on Method6 -- Add elements using keyed arrays
> global gTestArray
> put 0 into total
> repeat with x = 1 to 1000
> repeat with y = 1 to 1000
> add gTestArray[x,y] to total
> end repeat
> end repeat
> put "1,000,000 Element Sum = "&total
> end Method6
> --
>
Hi,
On my slowbook (400 mhz G4) Method6 takes around 27 - 28 seconds.
In this case "all" values are added. So if the handler is changed
accordingly:
on Method6 -- Add elements using keyed arrays
global gTestArray
put 0 into total
get the keys of gTestArray
repeat for each line i in it
add gTestArray[i] to total
end repeat
put "1,000,000 Element Sum = "&total
end Method6
It only takes between 5 - 6 seconds (on my slowbook)
Greetings,
Wouter
More information about the use-livecode
mailing list