FYI my test: cfif twice as fast as cfswitch, which is disappointing.

<cf_stopwatch>

<cfoutput>

<cfloop index="i" from="1" to="10000">

<cfswitch _expression_="#i mod 7#">

            <cfcase value="0">

                        red

            </cfcase>

            <cfcase value="1">

                        orange

            </cfcase>

            <cfcase value="2">

                        yellow

            </cfcase>

            <cfcase value="3">

                        green

            </cfcase>

            <cfcase value="4">

                        blue

            </cfcase>

            <cfcase value="5">

                        indigo

            </cfcase>

            <cfcase value="6">

                        violet

            </cfcase>

</cfswitch>

</cfloop>

</cfoutput>

</cf_stopwatch>

<cf_stopwatch>

<cfoutput>

<cfloop index="i" from="1" to="10000">

<cfif i mod 7 eq 0>

                        red

<cfelseif i mod 7 eq 1>

                        orange

<cfelseif i mod 7 eq 2>

                        yellow

<cfelseif i mod 7 eq 3>

                        green

<cfelseif i mod 7 eq 4>

                        blue

<cfelseif i mod 7 eq 5>

                        indigo

<cfelseif i mod 7 eq 6>

                        violet

</cfif>

</cfloop>

</cfoutput>

</cf_stopwatch>

-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED]
Sent: Thursday, 12 February 2004 10:45 a.m.
To: CF-Talk
Subject: RE: Which is quicker

Actually, they both only check until they find a match, assuming you're
using CFELSEIF in there to bind them all togther.

Both constructs are done as IF statements at the Java level, so you don't
get the 'usual' benefit of a switch construct.  CFSWITCH might be faster
(particularly if the _expression_ value is expensive to compute) if the CF
engine uses a temporary variable, but for simple expressions, that might
actually slow things down, because doing that's an extra step to do.

Cheers,
barneyb

> -----Original Message-----
> From: Bryan Stevenson [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 11, 2004 2:33 PM
> To: CF-Talk
> Subject: Re: Which is quicker
>
> CFCASE will be a tad quicker
>
> Basically CFIF has to check ALL conditions where CFCASE will
> stop when it finds the correct case.
>
> Bryan Stevenson B.Comm.
> VP & Director of E-Commerce Development
> Electric Edge Systems Group Inc.
> t. 250.920.8830
> e. [EMAIL PROTECTED]
>
> ---------------------------------------------------------
> Macromedia Associate Partner
> www.macromedia.com
> ---------------------------------------------------------
> Vancouver Island ColdFusion Users Group
> Founder & Director
> www.cfug-vancouverisland.com
>   ----- Original Message -----
>   From: Parker, Kevin
>   To: CF-Talk
>   Sent: Wednesday, February 11, 2004 2:29 PM
>   Subject: Which is quicker
>
>
>   Can I get a little advice on which is quicker or which is
> the preferred way
>   of programming - there are 8 items to select from:
>
>   CFIF, CFCASE or IIF
>
>   TIA!
>
>   +++++++++++++++++++
>   Kevin Parker
>   Web Services Manager
>   WorkCover Corporation
>
>   p: 08 8233 2548
>   e: [EMAIL PROTECTED]
>   w: www.workcover.com
>   +++++++++++++++++++
>
>   
> **************************************************************
> **********
>   This e-mail is intended for the use of the addressee only. It may
>   contain information that is protected by legislated confidentiality
>   and/or is legally privileged. If you are not the intended
> recipient you
>   are prohibited from disseminating, distributing or copying
> this e-mail.
>
>   Any opinion expressed in this e-mail may not necessarily be
> that of the
>   WorkCover Corporation of South Australia. Although precautions have
>   been taken, the sender cannot warrant that this e-mail or any files
>   transmitted with it are free of viruses or any other defect.
>
>   If you have received this e-mail in error, please notify the sender
>   immediately by return e-mail and destroy the original e-mail and any
>   copies.
>   
> **************************************************************
> **********
>
>

  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to