I have several reasons for not using evaluate:

1. I think it is *very* ugly.
2. I think that if you're using Evaluate() then you're probably not doing
something right, or you haven't thought it through fully.  There are a few
occasions where it is necessary, but not as often as it is used.  (Tie-in
with number 1: I have seen some *naaaasty* code that used Evaluate() all
over the place.  <shiver>)
3. It's is *much* slower than pretty much anything else.

Now, I know how much we hard-core geeks love metrics, so I'm going to
provide some for that last statement.  I ran time trials of assigments using
Evaluate() and the equivalent statements without it.  Results and the code
to generate them are below (remember that lower is faster and better):

Struct: 0,78,422,797,4000
Eval: 16,203,1063,2078,10422

Struct: 0,78,391,796,3984
Eval: 31,219,1046,2110,10438

Struct: 16,78,391,782,3984
Eval: 15,203,1016,2078,10375

Struct: 0,79,390,781,4015
Eval: 16,203,1031,2078,10532

Struct: 16,78,407,797,4000
Eval: 15,203,1046,2078,10453

The code:

<CFSETTING ENABLECFOUTPUTONLY="Yes">

<!---
  test.cfm
--->

<CFLOOP FROM="1" TO="5" INDEX="j">
  <CFSET StructTimes="">
  <CFSET EvalTimes="">
  <CFLOOP LIST="100,1000,5000,10000,50000" INDEX="Iterations">
    <CFSET Bag=StructNew()>
    <!--- set up our pile o' dummy vars --->
    <CFLOOP FROM="1" TO="#Iterations#" INDEX="i">
      <CFSET Bag["a#i#"]=Iterations - i>
    </CFLOOP>
    <!--- now test with structure calls --->
    <CFSET Start=GetTickCount()>
    <CFLOOP FROM="1" TO="#Iterations#" INDEX="i">
      <CFSET foo=Bag["a#i#"]>
    </CFLOOP>
    <CFSET End=GetTickCount()>
    <CFSET StructTimes=ListAppend(StructTimes,End-Start)>
    <!--- now test with Evaluate() calls --->
    <CFSET Start=GetTickCount()>
    <CFLOOP FROM="1" TO="#Iterations#" INDEX="i">
      <CFSET foo=Evaluate("Bag.a#i#")>
    </CFLOOP>
    <CFSET End=GetTickCount()>
    <CFSET EvalTimes=ListAppend(EvalTimes,End-Start)>
  </CFLOOP>
  <CFOUTPUT><P>Struct: #StructTimes#<BR>Eval: #EvalTimes#</P></CFOUTPUT>
</CFLOOP>

<CFSETTING ENABLECFOUTPUTONLY="No">

-----Original Message-----
From: Jeremy Allen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 31, 2000 1:24 PM
To: [EMAIL PROTECTED]
Subject: RE: getting data from queries as a structure/array


Why would you avoid using Evaluate I can think of
a few reasons but I am interested in hearing your
Reasons :)

Jeremy Allen
[EMAIL PROTECTED]

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to