Ahh, actually I just realised that this isn't a valid test. You are using the same set of variable names for both tests, therefore the cfscript test will always be faster as there is no variable assignment occuring in the cfscript block as the cfparams took care of it. Changing the variable names to Anewvar#i# for the cfparam and Bnewvar#i# for cfscript result in the following: [NB. I reduced count to 1000 as the test didn't scale well to 10000. Could probably fix by changing some JVM settings]
<cfparam> based: 844ms <cfscript> based: 781ms <cfparam> based: 625ms <cfscript> based: 812ms <cfparam> based: 813ms <cfscript> based: 859ms <cfparam> based: 641ms <cfscript> based: 797ms AND NOW, scoping the variables with "variables." so that CF doesn't have to do a scope traversal: <cfparam> based: 47ms <cfscript> based: 31ms <cfparam> based: 31ms <cfscript> based: 31ms <cfparam> based: 46ms <cfscript> based: 16ms <cfparam> based: 32ms <cfscript> based: 47ms <cfparam> based: 16ms <cfscript> based: 31ms NB. Turning the count back up to 10000 has no ill effects when the variables are scoped but I kept the count to 1000 for comparison purposes. Conclusions: 1) In both cases the appropriate scoping contributes massively to performance. 2) There is no discernable performance difference between cfscript and cfparam Will do a CF5 test after lunch. Steve > -----Original Message----- > From: Tim Blair [mailto:[EMAIL PROTECTED] > Sent: 01 April 2003 10:37 > To: [EMAIL PROTECTED] > Subject: RE: [ cf-dev ] : [ cf-dev ] cfTag best practises template > > > Before I start, apologies if you get a random blank message, > hit send by > accident and was too slow to stop it going! > > > Would be interesting to se MX's version of results. > > I ran a quick test and, er, wow: > > <!--- ---------------- cfparamtest.cfm ---------------- ---> > <cfset count = 10000> > > <cfset tagstart = gettickcount()> > <cfloop from="1" to="#count#" index="i"> > <cfparam name="newvar#i#" default="thing"> > </cfloop> > <cfset tagend = gettickcount()> > > <cfscript> > scriptstart = gettickcount(); > for (i=1; i LTE count; i = i+1) { > if (NOT isdefined("newvar#i#")) { "newvar#i#" = "thing"; } > } > scriptend = gettickcount(); > </cfscript> > > <cfoutput> > <cfparam> based: #tagend - tagstart#ms<br /> > <cfscript> based: #scriptend - scriptstart#ms<br /> > <cfscript> based saved #(tagend - tagstart + scriptend - > scriptstart) / count# ms per iteration over #count# tries > </cfoutput> > > <!--- ---------------- results (x5) ---------------- ---> > <cfparam> based: 32463ms > <cfscript> based: 225ms > <cfscript> based saved 3.2688 ms per iteration over 10000 tries > > <cfparam> based: 31143ms > <cfscript> based: 168ms > <cfscript> based saved 3.1311 ms per iteration over 10000 tries > > <cfparam> based: 32219ms > <cfscript> based: 163ms > <cfscript> based saved 3.2382 ms per iteration over 10000 tries > > <cfparam> based: 30814ms > <cfscript> based: 211ms > <cfscript> based saved 3.1025 ms per iteration over 10000 tries > > <cfparam> based: 33233ms > <cfscript> based: 173ms > <cfscript> based saved 3.3406 ms per iteration over 10000 tries > > <!--- ---------------- averages ---------------- ---> > <cfparam> based: 31974ms > <cfscript> based: 188ms > <cfscript> based saved 3.1801 ms per iteration over 10000 tries > > Tim. > > > ------------------------------------------------------- > RAWNET LTD - Internet, New Media and ebusiness Gurus. > Visit our new website at http://www.rawnet.com for > more information about our company, or call us anytime > on 01344 393 040. > ------------------------------------------------------- > Tim Blair > Web Application Engineer, Rawnet Limited > Direct Phone : +44 (0) 1344 393 441 > Switchboard : +44 (0) 1344 393 040 > ------------------------------------------------------- > This message may contain information which is legally > privileged and/or confidential. If you are not the > intended recipient, you are hereby notified that any > unauthorised disclosure, copying, distribution or use > of this information is strictly prohibited. Such > notification notwithstanding, any comments, opinions, > information or conclusions expressed in this message > are those of the originator, not of rawnet limited, > unless otherwise explicitly and independently indicated > by an authorised representative of rawnet limited. > ------------------------------------------------------- > > > > > -- > ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > For human help, e-mail: [EMAIL PROTECTED] > > -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
