Really? I'm getting about 50 and 150ms respectively. So for me while iif()
is slower it's only one hundredth of a millisecond difference i.e. way below
anything I'd worry about. So it's a style thing then.

-----Original Message-----
From: Tom Kitta [mailto:[EMAIL PROTECTED]
Sent: Thursday, 12 February 2004 11:11 a.m.
To: CF-Talk
Subject: RE: Which is quicker

You may get these results due to use of de(), run this code, which I think
is more fair:

<cfset temp = getTickCount()>

<cfoutput>
<cfloop index="i" from="1" to="10000">
<cfif i mod 2>1<cfelse>2</cfif>
</cfloop>
</cfoutput>

<cfoutput><h1>#temp-getTickCount()#</h1></cfoutput>

<cfset temp = getTickCount()>

<cfoutput>
<cfloop index="i" from="1" to="10000">
#iif(i mod 2, 1, 2)#
</cfloop>
</cfoutput>

<cfoutput><h1>#temp-getTickCount()#</h1></cfoutput>

I got 15 - 16 as results for both of them with some variations both ways
which I discard as noise.

TK
  -----Original Message-----
  From: Matthew Walker [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, February 11, 2004 5:57 PM
  To: CF-Talk
  Subject: RE: Which is quicker

  My test indicates iif() is about 400% slower. But the real issue is code
  readability. If you think it's more readable in any or all circumstances,
I
  say go for it. Personally, I think this example demonstrates it is less
  readable. There are probably other example that show it in a better light.

  Here's my sample:

  <cf_stopwatch>

  <cfoutput>

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

  <cfif i mod 2>!<cfelse>?</cfif>

  </cfloop>

  </cfoutput>

  </cf_stopwatch>

  <cf_stopwatch>

  <cfoutput>

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

  #iif(i mod 2, de("!"), de("?"))#

  </cfloop>

  </cfoutput>

  </cf_stopwatch>

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

  I don't know why people don't like iif (immediate if), it is as quick as
  cfif and takes only one line. For simple things, like "if x < y print true
  else print false", I think using iif makes code shorter without
sacrificing
  clarity and speed.

  If you don't believe iif is fast then I encourage you to write a small
test
  and see for yourself.

  TK
    -----Original Message-----
    From: Matthew Walker [mailto:[EMAIL PROTECTED]
    Sent: Wednesday, February 11, 2004 5:34 PM
    To: CF-Talk
    Subject: RE: Which is quicker

    cfswitch is both quicker and more elegant. The only downside is that it
    doesn't handle dynamic values.

    Iii() is one of those functions, like evaluate(), usage of which is
    generally discouraged.

    -----Original Message-----
    From: Parker, Kevin [mailto:[EMAIL PROTECTED]
    Sent: Thursday, 12 February 2004 10:30 a.m.
    To: CF-Talk
    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