Which is faster...
Bob Sneidar
bobsneidar at iotecdigital.com
Thu Dec 14 19:33:15 EST 2023
That is not exactly the test he was looking for. He wants to compare retrieving an array from a script local variable vs. getting a property of an object like a stack, that contains the same array. At least I think that is the question.
Now I’d like to discuss virtual properties. It takes the form:
Local lValueA
setProp myVirtualProperty, pValueA
Put pValueA into lValueA
End setProp
The reason this is really handy is because if pValueA is an array, you can then use the form:
getProp myVirtualProperty [pKey]
If pKey is not empty then
Return lValueA [pKey]
Else
Return tValueA
End getProp
In other words, you can get elements of the array without getting the entire array itself i.e.:
Put the myVirtualProperty [“companyname”] of myLivecodeObject into tCompanyName
I use this quite extensively. I have a single card which contains all the currently queried database data for caching purposes, along with the currently selected indexes for each datagrid, and the currently selected primary keys. I call the getProp and setProp handlers maingriddata. So I can:
Get the maingriddata [“hilitedkeys”] of tMainCard
Get the maingriddata [“hilitedindexes”] of tMainCard
Get the maingriddata [“customers”]
Put the queriedCustomersA into tMainGridDataA
Set the maingriddata to tMainGridDataA
And so forth. Any kind of logic can be used in the getProp and setProp handlers.
Bob S
> On Dec 14, 2023, at 2:25 PM, Craig Newman via use-livecode <use-livecode at lists.runrev.com> wrote:
>
> Anything to distract me from my day job.
>
> An array with 100,000 elements and a variable with 100,00 lines take the same time to place into a field.
>
> The only time that took a while was building them. Each took 10 milliseconds.
>
> Craig
>
>> On Dec 14, 2023, at 4:55 PM, Paul Dupuis via use-livecode <use-livecode at lists.runrev.com> wrote:
>>
>> Bob,
>>
>> Thank you. I could script a timing test but sometime just asking the list or forums is easier. You asnwered well before I would have had the time to write a basic test script. Thanks!
>>
>>
>> On 12/14/2023 4:45 PM, Bob Sneidar via use-livecode wrote:
>>> I think the confusion comes from thinking so much of a stack as an object that has substance, when really all the properties are places in memory just like a memory variable is. I asked this some years back and the answer I got was that there is no appreciable difference.
>>>
>>> One could always devise a test though…
>>>
>>> Bob S
>>>
>>>
>>> On Dec 14, 2023, at 1:22 PM, Paul Dupuis via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>
>>> Which is faster or more efficient (from an engine performance perspective)?
>>>
>>> To retrieve an array from a property?
>>> As in:
>>> command someHandler -- in an objects script
>>> get the cMyArray from me -- cMyArray is some multi-dimensional array
>>> ...
>>> end someHandler
>>>
>>> OR
>>>
>>> To retrieve an array from a script local variable?
>>> As in:
>>> local sMyArray -- script local variable in some objects script
>>>
>>> command someHandler -- in an objects script
>>> get sMyArray
>>> ...
>>> end someHandler
>>>
>>> Anyone know?
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list