I’ve been taking a fairly in depth look at JSP recently and come across some startling conclusions with regard to CF. For some background for those of you who don’t quite get it - Coldfusion compiles down to a Java .class file and then executes under Jrun as native Java code. JSP is fairly similar in this respect - JSP compiles down to a .class and runs on Jrun (may have an itermediary .java step on servers like Tomcat). JSP can also run natively on CFMX (Jrun) with no changes. So there I was writing some code in JSP and noticed that things were a lot more snappy than the equivalent Coldfusion so I put together some code for a little test.
Consider the following CF:
<cfset start = getTickCount()> <cfset result = 0> <cfloop from="1" to="1000000" index="i"> <cfset result = result + i> </cfloop> <cfoutput>#result# </cfoutput> <cfoutput>Execution Time: #getTickCount() - start#ms</cfoutput>
This code simply loops to a million and tots up a result in the process. The runtime? On my box around 3.5 seconds - OK fair enough.
Then I re-wrote the same code as a JSP (you are seeing the complete files here):
<%
long start = java.lang.System.currentTimeMillis();
long result = 0;
for (long i = 0; i < = 1000000; i++)
{
result += i;
}
%>
<%=result %>
<BR>
Execution Time: <%= java.lang.System.currentTimeMillis() - start %>ms.
Running this from the same folder, same URL on the same machine I was getting an execution time averaging around 10ms. Now, I’m no computer scientist - but two languages running the same process, compiling down the same code and executing on the same server is giving me execution times that are several hundered percent apart? Somethings going on there that is killing Coldfusion.
Question is what, does anyone have any ideas?
You will need some sort of ColdFusion hosting if you decide that your web design will incorporate ColdFusion, so before you invest in a host make sure that ColdFusion hosting is not only an option but a strong focus; and if you run a business then Exchange 2007 hosting may be your email solution.

