Making Revolution faster with really big arrays
Dennis Brown
see3d at writeme.com
Fri Apr 29 08:20:02 EDT 2005
Read the earlier versions of this thread for the fast methods. This
example is just for a specific test between Transcript and PostgreSQL
Dennis
On Apr 29, 2005, at 6:24 AM, Wouter wrote:
>
> 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 again with a little addition,
>
> The initialization of the test array takes about 36 seconds.
> Following version does the same in much shorter time:
>
> on mouseUp
> put the long seconds into zap
> --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 i = 1 to 1000
> put i&comma after x
> end repeat
> repeat 1000
> put x after gTestArray
> end repeat
> split gTestArray by comma
> put the long seconds - zap
> --end if
> put the long seconds into st
> Method6
> get the long seconds
> put " Elapsed Time ="&&(it - st)&&"seconds." after msg
> end mouseUp
>
> In this case the initialization takes about 10 seconds on the slowbook
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list