You are incorrect to state that <cfif variables.edible EQ TRUE> executes
faster. I did a small test with code underneath and in most executions it is
faster to do <cfif edible>. I always wondered to see what the difference
would be without using EQ. In some runs it was even 200%. On average it
looks like 50%. Here is the code:
<cfset huh = true>
<cfset start = getTickCount()>
<cfloop index="i" from="1" to="1000000">
<cfif huh>
<!--- empty --->
</cfif>
</cfloop>
<cfoutput>Count 1: #getTickCount()-start#</cfoutput>
<cfset start = getTickCount()>
<cfloop index="i" from="1" to="1000000">
<cfif variables.huh EQ TRUE>
<!--- empty --->
</cfif>
</cfloop>
<cfoutput>Count 2: #getTickCount()-start#</cfoutput>
Sample output:
Count 1: 1171 Count 2: 1704
There is a reason for this, it takes more time to use EQ since both left
and right side need to be evaluated, while with the 1st method that is not
needed (there is only one side and it is compared to static value of TRUE).
Also, variables with scope variables get executed first, so adding them
doesn't speed things up.
TK
[Tom Kitta] -----Original Message-----
From: Taco Fleur [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 29, 2004 3:02 PM
To: CF-Talk
Subject: RE: Best practises question
<cfif edible>
Is the easiest to write, however not the fastest to execute
<cfif variables.edible EQ TRUE>
executes faster
And its best practice to always scope your variables.
<cfset arr_fruit=ArrayNew(1)>
<cfset arr_fruit[1]="apple">
<cfset arr_fruit[2]="banana">
<cfset arr_fruit[3]="pear">
<cfset edible = ArrayAppend(arr_fruit,"pineapple")>
I also not sure that your example really displays correctly, i.e. you are
creating an array and in the cfif example you check a simple value for
yes,
true or 1
<!--- <cfif edible IS "YES"> --->
or
<!--- <cfif edible IS true> --->
or
<cfif edible IS 1>
More fruit added to arr_fruit
<cfelse>
NO fruit added
</cfif>
While it should be
<!--- <cfif edible[1] IS "apple"> --->
Etc...
Taco Fleur
Blog <http://www.tacofleur.com/index/blog/>
http://www.tacofleur.com/index/blog/
Methodology http://www.tacofleur.com/index/methodology/
0421 851 786
Tell me and I will forget
Show me and I will remember
Teach me and I will learn
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
- Best practises question David Adams
- Re: Best practises question Jochem van Dieten
- RE: Best practises question Taco Fleur
- Re: Best practises question Tom Kitta
- Re: Best practises question Jochem van Dieten
- RE: Best practises questi... Taco Fleur
- Changing HTML text t... Stuart Kidd
- Re:Changing HTML... Josen Ruiseco
- RE: Best practises question Tony Weeg
- RE: Best practises question Qasim Rasheed
- RE: Best practises question Tony Weeg
- Re: Best practises question Josh
- RE: Best practises question Stephen Barry
- RE: Best practises question Hagan, Ryan Mr (Contractor ACI)