I did some testing early last year some time and found no real speed
difference.
I tested
<cfparam name="client.example" default="am i faster">
OR
<cfif not isDefined("client.example")>
<cfset client.example = "or am i faster">
</cfif>
OR
<cfscript>
if ( isdefined("x")
{
x = "or am I faster";
}
</cfscript>
They all came out to be just about the same for a single variable being set
or not set.
CFScript preformed better if you had 3+ if isdefined() set combos that
needed to be set.
example
<cfscript>
if ( isdefined("x")
{
x = "or am I faster";
}
if ( isdefined("y")
{
y = "or am I faster";
}
if ( isdefined("z")
{
x = "or am I faster";
}
</cfscript>
Was faster than 3 cfparams. But that comes from CFScripts speed at vantage
when setting variables. There were variance in the speeds for each but over
all I decided on readability. What code is easier to read.
<cfparam name="x" default="am i faster">
<cfparam name="y" default="am i faster">
<cfparam name="z" default="am i faster">
or the above CFScript example that sets the same 3 variables. I think the 3
cfparams are easier to take in at a glance and faster to right then the
CFScript or <cfif versions. CFParam has less room for error than the other
was of righting it. How many people caught my error in the CFScript example
(the third check to see if "z" is defined and set "x" oops). So if you
don't make mistakes and want the small speed increase play with them and
find out which one works best for you. I use CFPARAM it is simple and not
to slow and falls with in KISS. If you do find one to be greatly faster
than the other in 4.5 SP2 let me know my test were under 4.01 but I need to
see probably 30%+ speed advantage and I still probably would not make a
change for fear of making a mistake because I now have 3+ lines of code
where I only need 1. If there are other things that need to happen at the
same time as setting the undefined variable then use an if isdefined set
style but if all you need is a cfparam use the tool that is there(unless it
is extremely slow my test found no major speed enhancements).
Daniel D.
-----Original Message-----
From: Brunelle, John [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 20, 2001 11:46 AM
To: Fusebox
Subject: <cfparam> vs isDefined()
Just curious if anybody has looked at the difference between
using the <cfparam> tag and using the isDefined() function.
For instance: in the Application.cfm or the app_global.cfm file.
If I have a global variable that I would like to prevent from setting
and resetting everytime the file is executed. Would I be better off using
<cfparam> or isDefined().
example:
global variable: client.example
<cfparam name="client.example" default="am i faster">
OR
<cfif not isDefined("client.example")>
<cfset client.example = "or am i faster">
</cfif>
My thought here is that internally the <cfparam> tag
is really a kind of isDefined() function. Yet, being
that this will execute for every single page catches
my curiousity.
Any thoughts?????
Thanks,
John Brunelle
FMHI Web Programmer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists