Silence

A major disadvantage of generated code is the size of the generated html. When you have something like <cfscript> this may not be an issue since the complete code generates no output unless you use something like echo() or writeOutput().

A bit of testing by using the unpopular atomar test routines produced some curious results. Here's the code:


<cfsilent>
    <cfinclude template="setVariable_withSpaces.cfm">
</cfsilent>

setVariable_withSpaces.cfm:
1:     <cfloop from="1" to="100000" index="i">
2:         // many empty lines

3:         <cfset a = i>
4:         // many empty lines

5:         <cfset b = a>
6:         // many empty lines

7:     </cfloop>

Without a <cfsilent> around the following results came up:
MX: 281ms
Railo 1.0: 156ms
Railo 1.1: 148ms

If I surround lines 1 to 7 with a <cfsilent> MX beats Railo 1.0!!!

With <cfsilent> around lines 1-7:
MX: 125ms
Railo 1.0: 154ms
Railo 1.1: 78ms

But why? Well the reason is that <cfsilent> for MX is kind of a compiler command which causes MX to remove unused spaces, tabs, cr's and lf's from the code before compiling it (or compiling it without these outputs). Railo generates these outputs and writes them into the void. But the output in Railo is still done, even though it is not necessary. In Railo 1.1 we wanted to correct this misbehaviour. Now in Railo every unused space between the opening and closing <cfsilent> tag is removed (unless there is a tag named <cfsavecontent>, <cfmail> etc. included inside the <cfsilent> tag. This is done by Railo at compile time.
Now there's more. Even with the argument output="no" unused space is removed in functions or components. In MX this is not the case. Take the following code:


    <cfset iTime = getTickCount()>
    <cfsilent>
        <cfset loopCall()>
    </cfsilent>
    <cfset iTime = getTickCount() - iTime>

<cffunction name="loopCall" output="No" returntype="boolean">
    <cfloop from="1" to="1000000" index="i">
    

    <cfset a = 5>


    <cfif a eq 6>
        <cfset b = 2>
    </cfif>


    </cfloop>
</cffunction>

This code executes in 4600ms in MX. If I surround the body of the function with a <cfsilent> it then executes in 3400ms. ??? I guess this is because in the case of output="no" MX reacts as Railo 1.0 did with <cfsilent>. The output is generated but written into the void. By adding &cfsilent> to a function that generates no output you can gain performance with MX. Allthough it does not lead to a different output. It's still empty :-)
Railo 1.1 at compile time removes the space between <cfsilent> and from functions that produce no output because of the attribute output="no".

While Railo 1.0 executes the code above with or without the <cfsilent> tag in 1700ms Railo 1.1 executes the same code in 1250ms.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact Blog Owner