Bryan Stevenson wrote:
> Erg....write less efficient code for the sake of possible future
> developers!!!???
>
> How about keeping the more efficient code and commenting it so those future
> developers will understand it ;-)
For a little fun I wrote some code to test the performance difference
between <CFIF X> and <CFIF X gt 0>
I did 100,000 iterations each on my relatively slow server (566 celeron
with 256MB of RAM), running CF 5.0. I repeated the test three times.
<CFIF X> took 16,16, seconds
<CFIF X gt 0> took 18,17,18 seconds
If your site gets 1 million page views a day (WOW!) and each of those
has 10 such evaluations... that's 10 million evaluations and a total
of 200 seconds additional processing time per day. Assuming you have
a old slow system.
I ran the same code on my desktop, which is running the CFMX Triale, has
a 2ghz processor and 1GB of RAM.
Both took 0 seconds to complete. I upped the repetition to a 10
million, and each took 14 seconds.
SO... all that being given... I'll take the readable code over
the "performance increase".
- Rick
<CFSETTING ENABLECFOUTPUTONLY="Yes">
<CFSET ITERATIONS = 100000>
<CFSET Before = Now()>
<CFSET COUNTER = 0>
<CFLOOP FROM="0" TO="#ITERATIONS#" STEP="1" INDEX="X">
<CFIF X>
<CFSET COUNTER = COUNTER + 1>
</CFIF>
</CFLOOP>
<CFSET After = Now()>
<CFOUTPUT>#COUNTER# - Completed in #DateDiff('s',Before,After)#
seconds</CFOUTPUT>
<CFSET Before = Now()>
<CFSET COUNTER = 0>
<CFLOOP FROM="0" TO="#ITERATIONS#" STEP="1" INDEX="X">
<CFIF X>
<CFSET COUNTER = COUNTER + 1>
</CFIF>
</CFLOOP>
<CFSET After = Now()>
<CFOUTPUT><BR>#COUNTER# - Completed in #DateDiff('s',Before,After)#
seconds</CFOUTPUT>
<CFSETTING ENABLECFOUTPUTONLY="No">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com