I got curious and tested it out for myself.  Here's the results:

cfscript switch - 600 ms
cfswitch - 181 ms

for this code:

<cfset time1 = gettickcount()>
<cfscript>
j = 0;
i = 0;

for (i = 1;i lte 1000;i=incrementvalue(i)) {
 j = RandRange(1,10000);

 switch (j) {
  case "j lte 250": {
   j = j +1;
   break;
  }
  case "j lte 500": {
   j=j+1;
   break;
  }
  case "j lte 750": {
   j=j+1;
   break;
  }
  case "j lte 1000": {
   j=j+1;
   break;
  }
 }

}

</cfscript>
<cfset out = GetTickcount() - time1>
<cfoutput>cfscript switch - #out# ms</cfoutput>
<cfset time1 = getTickCount()>

<cfset j=0>
<cfset i=0>

<cfloop from="1" to="1000" index="i">
 <cfset j=RandRange(1,10000)>
 <cfswitch expression="j">
  <cfcase value="j lte 250">
   <cfset j = j +1>
  </cfcase>
  <cfcase value="j lte 500">
   <cfset j = j +1>
  </cfcase>
  <cfcase value="j lte 750">
   <cfset j = j +1>
  </cfcase>
  <cfcase value="j lte 1000">
   <cfset j = j +1>
  </cfcase>
 </cfswitch>
</cfloop>

<cfset out = GetTickcount() - time1>
<cfoutput><br>cfswitch - #out# ms</cfoutput>
----- Original Message -----
From: "Marlon Moyer" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, April 19, 2002 12:54 PM
Subject: cfswitch vs switch


> I seem to remember hearing that the cfscript switch statement is a dog
compared to the equivalent cfswitch code...Is this correct?
>
>
> Marlon
>
>
> 
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to