Why is dispatch so fast?
Richard Gaskin
ambassador at fourthworld.com
Mon Nov 11 22:06:29 EST 2013
Mark Wieder wrote:
> Saturday, November 9, 2013, 10:30:38 PM, Richard wrote:
>
>>> Why is the dispatch command so much faster than do, send, or call?
>
>> The main difference appears to be send needs to parse the params
>> from the string. Do obviously needs to be parsed on the fly too.
>
> Yes, it's the runtime parsing that slows these down.
Here's an example where the overhead should be the same, yet dispatch
takes only 287 ms to do's 405 ms:
on mouseUp
put 100000 into n
put "foo" into tCmd
--
-- Test 1: Do
put the millisecs into t
repeat n
do tCmd
end repeat
put the millisecs - t into t1
--
-- Test 2: Dispatch
put the millisecs into t
repeat n
dispatch tCmd
end repeat
put the millisecs - t into t2
--
put t1 && t2
end mouseUp
on foo
get 1+1
end foo
--
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