title: prove that coldfusion functions unnecessarily buffer with output=true
body: <p>I've heard that if you do not specify <code>output="false"</code> on a ColdFusion function that unnecessary buffering would occur which could hinder performance.  So I wanted to run a test to see if I could prove this.  My test is below.  I saw no difference at all between <code>output="true"</code> or <code>output="false"</code>.</p>
  
  <p><strong>So my question is: if I have functions used within large loops should I not have to worry about this setting?  Or am I not testing this correctly?</strong></p>
  
  <p>My test was to call the same function 1,000,000 times.  I ran it 3 times with <code>output="false"</code> and 3 times with <code>output="true"</code>.  All 6 tests finished at exactly 20-21 seconds.</p>
  
  <p><img src="https://i.stack.imgur.com/cG5Gf.jpg" alt="enter image description here"></p>
  
  <p>The Test Code:</p>
  
  <pre><code>&lt;cffunction name="good" output="false" returntype="Numeric" access="private"&gt;
      &lt;cfargument name="numIn" type="numeric" required="true"&gt;
      &lt;cfset var x = 0&gt;
      &lt;cfset x = arguments.numIn + 1&gt;
      &lt;cfreturn x&gt;
  &lt;/cffunction&gt;
  
  &lt;cffunction name="bad" output="true" returntype="Numeric" access="private"&gt;
      &lt;cfargument name="numIn" type="numeric" required="true"&gt;
      &lt;cfset var x = 0&gt;
      &lt;cfset x = arguments.numIn + 1&gt;
      &lt;cfreturn x&gt;
  &lt;/cffunction&gt;
  
  &lt;cfset loopNum = 1000000&gt;
  
  &lt;cfset x = 0&gt;
  &lt;cfoutput&gt;
      x = #x#&lt;br&gt;
      Running bad function #loopNum# times...&lt;br&gt;
  &lt;/cfoutput&gt;
  &lt;cfset tBegin = GetTickCount()&gt;
  &lt;cfloop from="1" to="#loopNum#" index="i"&gt;
      &lt;cfset x = bad(i)&gt;
  &lt;/cfloop&gt;
  &lt;cfset tEnd = GetTickCount()&gt;
  &lt;cfset scriptTime = (tEnd - tBegin)&gt;
  &lt;cfoutput&gt;
      x = #x#&lt;br&gt;
      Time to complete: #scriptTime#&lt;br&gt;
  &lt;/cfoutput&gt;
  
  &lt;!---
  &lt;cfset x = 0&gt;
  &lt;cfoutput&gt;
      x = #x#&lt;br&gt;
      Running good function #loopNum# times...&lt;br&gt;
  &lt;/cfoutput&gt;
  &lt;cfset tBegin = GetTickCount()&gt;
  &lt;cfloop from="1" to="#loopNum#" index="i"&gt;
      &lt;cfset x = good(i)&gt;
  &lt;/cfloop&gt;
  &lt;cfset tEnd = GetTickCount()&gt;
  &lt;cfset scriptTime = (tEnd - tBegin)&gt;
  &lt;cfoutput&gt;
      x = #x#&lt;br&gt;
      Time to complete: #scriptTime#&lt;br&gt;
  &lt;/cfoutput&gt;
  ---&gt;
  </code></pre>