Speed boost with private handlers?

Richard Gaskin ambassador at fourthworld.com
Wed Jun 20 14:52:43 EDT 2007


Wilhelm Sanke wrote:
> The "What's new" text and the "Engine Change Log" for 2.8.1 state for 
> "private handlers" that there is a "speed boost as private handlers do 
> not have to go through the message path".
> 
> Has anybody experienced such a "speed boost" and could he/she provide a 
> sample script or sample stack where such a speed boost is apparent and 
> can be measured in comparison with a non-private handler?

Thanks for bringing this up.  It was interesting enough to run a quick 
test, and it seems the lookup time for private handlers is quite a bit 
shorter than for handlers one level down the message path - here's the 
result of my test:

   Mesage path: 168ms for 100000 iterations (0.00168ms each)
   Private:      94ms for 100000 iterations (0.00094ms each)

While the relative speed is impressive, it's worth noting that the 
"slowest" of the two still only takes 0.00168ms per call.

Here's the test I ran:


-- This script is in a button:
on mouseUp
   put 100000 into n
   --
   put the millisecs into t
   repeat n
     Test1
   end repeat
   put the millisecs - t into t1
   --
   put the millisecs into t
   repeat n
     Test2
   end repeat
   put the millisecs - t into t2
   --
   put "Mesage path: "&t1 &"ms for "&n&" iterations ("& t1/n&"ms each)"\
     &cr&"Private: "& t2 &"ms for "&n&" iterations ("& t2/n&"ms each)"
end mouseUp

private command Test2
   get 1+1
end Test2



-- This is in the card script:
on Test1
   get 1+1
end Test1



-- 
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com



More information about the use-livecode mailing list