On 23 Apr 2009, at 11:02, <[email protected]> <[email protected]> wrote:

All ,

Which is faster in a loop ?

SWITCH or IF



This is a little test I did. I get about 35ms for 'switch', about 20ms for 'if'. As Jim said though, I suspect it'll vary according to the kind and complexity of conditions you're testing.


on mouseUp
   put the millisecs into tStart
   repeat 10000
      put random(5) into tSw
      switchTest tSw
   end repeat
   put the millisecs - tStart into t1

   put the millisecs into tStart
   repeat 10000
      put random(5) into tIf
      ifTest tIf
   end repeat
   put the millisecs - tStart into t2

   put t1 && t2
end mouseUp

-----

on switchTest pSw
   switch pSw
      case 1

         break
      case 2

         break
      case 3

         break
      case 4

         break
      default

         break
   end switch
end switchTest

-----

on ifTest pIf
   if pIf = 1 then

   else if pIf = 2 then

   else if pIf = 3 then

   else if pIf = 4 then

   else

   end if
end ifTest

Best,

Mark
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to