Quoted or unquoted literals

Richard Gaskin ambassador at fourthworld.com
Tue May 12 12:34:06 EDT 2009


René Micout wrote:
> Jacqueline,
> You said yesterday (?) that using synonym like "cd", "btn", "fld" is  
> slower than "card", button", "field". That is, I think, an  
> interesting problem because I use synonym every time...
> What is the difference (speed) ?

Not enough to bother with, IMO.

I ran this test:

on mouseUp
   put 100000 into n
   --  Abbrev:
   put the millisecs into t
   repeat n
     set the uX of sb 1 to the text of fld 1
   end repeat
   put the millisecs - t into t1
   -- Full:
   put the millisecs into t
   repeat n
     set the uX of scrollbar 1 to the text of field 1
   end repeat
   put the millisecs - t into t2
   --
   put "Abbrev: "& t1/n && "  Full: "& t2/n &\
       cr& "Difference: "& t1/n - t2/n
end mouseUp

...and got this result:

Abbrev: 0.00213   Full: 0.00211
Difference: 0.00002


I'm normally quick to adopt habits which will optimize performance, 
knowing that every clock cycle saved is one I can put toward 
bullet-point features, but on this one the productivity loss of typing 
the full form for all object references isn't worth the 0.00002 
millisecond to me.

No doubt this difference would be much greater if one were doing this in 
a "send", "do" or "value" call because those need to run through the 
compiler in each iteration.  But for that reason I use those as seldom 
as possible anyway;  the overhead of using "send" is orders of magnitude 
more than the overhead of using abbreviations.

It's still not the end of the world to use "send", and when you need it 
you need it.  But avoiding "send", "do", or "value" where practical will 
save you much more time than avoiding abbreviations.

Besides, with "dispatch" and behaviors in v3.5 I rarely use "send" these 
days.  "Dispatch" is similar to send in many ways, and AFAIK it still 
needs to be runtime-compiled, but something about it is optimized so 
that it benchmarks at least 30% faster.

--
  Richard Gaskin
  Fourth World
  Revolution training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com



More information about the use-livecode mailing list