Yes... that's true. If you even scope the variables from the variables scope
(EXCEPT in components, since they have their own variables scope) CF is
around 4 times slower than addressing a variable from there without the
prefix "variables". But this execution isn't very significant when your
website is quite slow. It is 4 times faster not to scope variables from the
variables scope, but in reality you won't notice that much improvement since
accessing variables in comparison to querying a database is really a matter
of order of magnitudes (So maybe "variables.whatever" executes in 12 nano
seconds, where as "whatever" executes in 3 nano seconds, whereas a query
will take 1ms which is 1000 nano seconds).

In Railo you can enable a setting that actually forces you to scope your
variables from the various scopes. So for instance if you do something like
this:
<cfoutput>#id#</cfoutput> 
and ID is in the URL scope Railo will complain that it doesn't know the
variable ID (if this setting is turned on) and throw an error. So you HAVE
TO write it like this:
<cfoutput>#url.id#</cfoutput>
Then Railo processes the page without error.
Once you have scoped all your variables the system will be somewhat faster. 

Just imagine it like this:
You are searching for a Peter (a variable) in a school (CF memory). You
enter every classroom (scope) and check whether a pupil named "Peter" is
sitting in it. If you find it, that’s your variable. But if you know that
Peter is sitting in the classroom number 55 then you go directly there and
look for Peter. With the scope cascading disabled, Railo will not allow you
to look for a "Peter" in the school without the classroom number.

Hope that helps a little.

Greetings from Switzerland
Gert Franz

Railo Technologies      Professional Open Source
skype: gert.franz       g...@getrailo.com
+41 76 5680 231 www.getrailo.com

-----Ursprüngliche Nachricht-----
Von: Charlie Griefer [mailto:charlie.grie...@gmail.com] 
Gesendet: Donnerstag, 10. Dezember 2009 16:59
An: cf-talk
Betreff: Re: scoping and speed


In theory, yes, as ColdFusion will have to hunt through the various scopes
to find the exact variable that you're referencing.

Whether it's noticeable or not.. hard to say.

>From the CF8 docs (
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Variables_
32.html
):

"Because ColdFusion must search for variables when you do not specify the
scope, you can improve performance by specifying the scope for all
variables."

I do actually recall hearing that on Railo, it was faster to -not- scope
local variables.  Not sure if that still holds true or not.

On Thu, Dec 10, 2009 at 7:13 AM, Chad Gray <cg...@careyweb.com> wrote:

>
> If you don't scope your local variables does the page run slower?
>
> IE. #variables.foo# vs. #foo#
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329053
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to