Skip to main content
September 2, 2009
Question

cfscript function vs cffunction

  • September 2, 2009
  • 2 replies
  • 1800 views

Just passing on something I ran across recently:  I have a page that has 2 nested CFLOOP's, and a UDF function call inside the inner loop.  The page was consistently taking about 75 seconds to run.  Just out of curiousity, I changed the UDF from a CFSCRIPT function to a CFFUNCTION, and the load time went from 75 seconds to less than 5.  At first I thought I broke it, and it was not really running, but it was I double-checked, and it was running properly and returning the same results.  Probably not significant if a function is called 1 or 2 times on a page, but if it's 100's or 1000's, it could be a big improvement.  This is CF8.

    This topic has been closed for replies.

    2 replies

    Inspiring
    September 3, 2009

    Can you post the code?

    --

    Adam

    September 3, 2009

    I was originally working on this a couple of months ago, but didn't have time to post this then due to a long vacation soon after that.  Since then the code has evolved, and I don't have an exact example to post.  But after thinking back, I believe the 2 nested CFLOOPs were actually inside a CFOUTPUT loop.  So with 3 nested loops, the function could have been executing 100,000 times (or more) on one page.  Even if just a fraction of a second improvement, this would be a major difference.  I'm guessing the CFFUNCTION somehow keeps itself instantiated memory, so that later calls are faster?

    I have since done this translation to CFFUNCTION in other places with minor improvements, but these are being called many times fewer on a page.

    Whenever comparing execution times, I do reload the original several times, and then reload the revised several times...  just to make sure the results are consistent and accurate.

    Inspiring
    September 3, 2009

    Fair enough.

    One thing about your follow-up post concerns me - in an unrelated way - though:

    the code has evolved, and I don't have an exact example to post.

    This suggests to me that you are possibly not using source control on your code?  If not, you really really really should be.

    http://subversion.tigris.org/

    --

    Adam

    Adobe Employee
    September 3, 2009

    That is something difficicult to believe. Will it be possible for you to log a bug and post the repro case there?

    http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html