I think a fairer comparison would be to use the following JSP code.

<%
  Long loops = new Long(1000000);
  long sTime = 0;
  long eTime = 0;
  Long r = new Long(0);
  double i = 0D;
  
  out.println(loops + " Loops<br>");
  sTime = System.currentTimeMillis();
  out.println(sTime + "ms Start Time<br>");
  for(Long x = new Long(1); x.longValue() <= loops.longValue(); x = new
Long(x.longValue() + 1))
   r = new Long(r.longValue() + x.longValue());

  eTime = System.currentTimeMillis();  
  out.println(r + " Result<br>");  
  out.println(eTime + "ms End Time<br>"); 
  out.println((eTime - sTime) + "ms Execution Time<br>");
  i = (eTime - sTime) / 1000;
  out.println(i + "seconds");
%>

While the above is closer to the work the CF version has to do, it is
still missing some casting overhead. This is because in CFMX all simple
CF variables are stored using coldfusion.runtime.Variable, which
actually stores the value as java.lang.Object. Thus, numerical
comparisons can't be performed until the Objects are cast into
appropriate types.

Matt Liotta
President & CEO
Montara Software, Inc.
http://www.montarasoftware.com/
888-408-0900 x901

> -----Original Message-----
> From: Gaulin, Mark [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 17, 2002 8:16 AM
> To: CF-Talk
> Subject: RE: FW: Jsp Vs Cfm (CFMX) -- Test Code
> 
> It seems to me that a code written in JSP or java has the benefit of
being
> strongly typed... that "long loops" definition in the JSP code is very
> significant to a compiler. Try running that loop again using "new
Integer"
> in each iteration and see what you get.
> 
> CF-translated code may be compiled into bytecode, but unless it is
doing
> some serious optimization it cannot infer that the looping variable is
> really an int, and that implies that it must be treating it like an
> object.
> Anybody try decompiling mx generated class files (assuming they
exist)?
> That
> will tell you a big part of the story.
> 
>       Mark
> 
> -----Original Message-----
> From: Joe Eugene [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 17, 2002 11:08 AM
> To: CF-Talk
> Subject: RE: FW: Jsp Vs Cfm (CFMX) -- Test Code
> 
> 
> Dick,
>       CFMX Enterprise was showing the below results for me
> 
>       Jsp=20ms
>       Cfm=3064ms
> 
>       consistently. Increasing the loops *Jsp* seemed to perform
well..
>       Cfm started to die off.
>       I happen to notice one abnormal behaviour as well for *.cfm
>       loops=1000000
>       for(x=1;x lte loops;x=x+1)
>       If you reference the variable like "x lte loops" ,CFMX takes a
hefty
>       8903ms to run the code. I have no idea.. why this is happening.
> 
>       Anyways.. i think it comes down to the fact that the CFMX
compiler
>       needs to produce more optimized Serlvet/bytecode.
>       I wonder how the CFMX compiler transforms *.cfm into servlet
code?
>       Does CFMX actually change CFM Code to *Strong type*(int, String,
> double
> etc)?
>       if this is the case...we shouldnt see the huge performance
> difference.
> Joe
> 
> 
> 
> > -----Original Message-----
> > From: Dick Applebaum [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, September 17, 2002 8:27 AM
> > To: CF-Talk
> > Subject: Re: FW: Jsp Vs Cfm (CFMX) -- Test Code
> >
> >
> > Joe
> >
> > I didn't try the code, at first,  because I can't run jsp under CFMX
on
> > the Mac.
> >
> > After your email I tried the comparison using jsp under Tomcat
> > jwsdp-1_0-ea2.
> >
> > The results I got are significant.
> >
> > The cfm program consistently takes more than 40-80 times longer to
run
> > than the jsp program (under Tomcat), for example:
> >
> >      cfm:  4110 ms
> >      jsp:       50 ms
> >
> > I fiddled with the program to make sure the actual loop was as
similar
> > as possible and that nothing but the loop was within the timing --
no
> > significant affect.
> >
> > I tried longer loops with similar results.
> >
> > I changed the test to lt (<) instead of lte (<=), similar results.
> >
> > I changed the jsp increment x++ to match cfm's x=x+1 -- similar
results.
> >
> > On Mac OS X both Tomcat and CFMX/JRun use the same underlying (Mac
OS
> > X) JVM (not the one installed with CFMX).
> >
> > The problem appears to be whatever CFMX uses to generate a Java
> > program, is doing it (at least this loop) very inefficiently.
> >
> > Anyone else have any ideas?
> >
> > Dick
> >
> >
> >
> > > In reply to my Original Post for anybody interested in the Test
code
> > > Jsp code implemented in a Java class compiled with J2SE(JDK 1.4.1
RC)
> > > produced the
> > > same results as CFMX Jsp code.
> > >
> > > <!--- Jsp Code, cut and paste in a *.jsp file. This is for CFMX
> > > Enterprise --->
> > > <%
> > >   long loops=1000000,sTime=0,eTime=0,r=0;
> > >   double i=0;
> > >   out.println(loops +" Loops<br>");
> > >   sTime=System.currentTimeMillis();
> > >   out.println(+sTime+"ms Start Time<br>");
> > >   for(long x=1;x<=loops;x++){
> > >    r=r+x;
> > >  }
> > >   eTime=System.currentTimeMillis();
> > >   out.println(r+" Result<br>");
> > >   out.println(eTime+"ms End Time<br>");
> > >   out.println((eTime-sTime)+"ms Execution Time<br>");
> > >   i=(eTime-sTime)/1000;
> > >   out.println(i+"seconds");
> > > %>
> > >
> > > <!-- Cfm Code, "loops" var in the for statement took more than
double
> > > the
> > > time to run, i am not sure why? -->
> > > <cfscript>
> > > loops=1000000;z=0;
> > > writeOutput(loops & " Loops<br>");
> > > sTime=GetTickCount();
> > > writeOutput(sTime & "ms Start Time<br>");
> > > for(x=1;x lte 1000000;x=x+1)/*<=loops takes more than double the
> time*/
> > >  {z=z+x;}
> > > eTime=GetTickCount();
> > > writeOutput(z & " Result<br>");
> > > writeOutput(eTime & "ms End Time<br>");
> > > writeOutput(eTime-sTime&"ms Execution Time<br>");
> > > writeOutput((eTime-sTime)/1000&"seconds");
> > > </cfscript>
> > >
> > >
> > > Joe Eugene
> > > Certified Advanced ColdFusion Developer
> > >
> >
> >
> 
> 
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to