ID caching: how to test?

Richard Gaskin ambassador at fourthworld.com
Sun May 12 13:39:41 EDT 2013


Alex Tweedly wrote:

> 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

Nicely done, Alex.  Thanks!

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for Desktop, Mobile, and Web
  ____________________________________________________________
  Ambassador at FourthWorld.com        http://www.FourthWorld.com




More information about the use-livecode mailing list