ID caching: how to test?

Alex Tweedly alex at tweedly.net
Sun May 12 13:08:00 EDT 2013


Yes, here's an example. The clue (I think) is in the "linear time...into 
constant time"

Create a large-ish number of controls - in this stack I cloned a button 
1000 times, calling them
BBB1   BBB2 .... BBB1000

Then this code accesses a single control many times - and shows that 
accessing by id is much faster than accessing by name, but more 
importantly here, that in 6.0 access by id to the most recently accessed 
control is very fast.

in 5.5.3
name takes 830 ms while id takes only 250 ms

but in 6.0 (i.e. with id caching)
name takes 830 ms while id takes 5 ms

-- Alex.



global K

on mouseUp
    put 1000 into K

    put the millisecs into t1
    put "BBB"&(K-10) into tName
    repeat 10000 times
       put the short name of control tName  into t
    end repeat
    put the millisecs-t1 && t &CR after msg

    put the millisecs into t1
    put the id of button tName into tID
    repeat 10000 times
       put the short name of control id tID  into t
    end repeat
    put the millisecs-t1 && t &CR after msg

end mouseUp



On 11/05/2013 03:11, Richard Gaskin wrote:
> The Release Notes for v6 include:
>
>   ID caching (6.0 DP 2)
>   New global property – allowDatagramBroadcasts (6.0 DP 2)
>   A new global property allowDatagramBroadcasts has been added. This
>   needs to be set to true before sending to a broadcast address
>   (enables the per-socket flag for whether they are allowed).
>   The engine now caches lookups of control references of the form
>   “card id ...” and “control id ...”.
>   This speeds up any access using those forms after the first time,
>   turning an operation that would be completed in linear time into
>   one that will be completed in constant time.
>
>
> I'm not clear on the syntax, so I've been unable to benchmark the 
> performance boost.
>
> Anyone here have a sample of ID caching in action?
>
> -- 
>  Richard Gaskin
>  Fourth World
>  LiveCode training and consulting: http://www.fourthworld.com
>  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
>  Follow me on Twitter:  http://twitter.com/FourthWorldSys
>
> _______________________________________________
> 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