Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfinvoke vs createobject

Contributor ,
Dec 16, 2011 Dec 16, 2011

I have a bunch of web apps that use <cfinvoke> statements to call CFCs.  After a recent CF Server Admin class, our instructor mentioned that <cfinvoke> was VERY slow, and that I should be using CreateObject() instead, because it's more efficient.

So my question is, has anyone done any comparisons to see the actual difference?  I'm curious to hear other people's experiences with this.

8.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 18, 2011 Dec 18, 2011

Incidentally... you know how people bang on about not being able to paste code into these forums?  I had a bit of a problem getting test.cfm's code to paste in the: the forum seemed to want to try to put the code into a table, which munged it up somewhat.

It turned out it was due to the tabs I had WITHIN tags (eg: my attributes in my <cfparam> tags were vertically aligned for readability).  If I took those out and only had leading tabs, then it pasted OK.  I wonder if it's that sort of thing that causes other people grief?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2011 Dec 18, 2011

Did your sodas stay safe, Dave?

They did!

Using BKBK's script, I got this:

createobject execution time: 30

cfinvoke execution time: 20

The CFC just did a select from a tiny database and cfdumped the results, so it's not much of a load.

This was CF9 and MySQL on Ubuntu 10.10 (my local machine).

cfinvoke seems to be faster, but perhaps it hogs more resources?

I would merely echo the things said by Adam and BKBK since then - build an independent test that doesn't involve other resources like a database, and test multiple iterations - and add one thing. To test something like this, you need to test it in parallel, not serially, as that's how people are going to run your applications. In other words, you need to do load testing to determine an absolute answer to a question like this.

That all said, Adam's test matched my anecdotal experience and my expectations - there really isn't much of a difference. Going back to your original question, I strongly suspect that your instructor's point was on instantiation of objects and how this can make a significant impact on performance, rather than just the question on its face about CFINVOKE vs createObject.

Dave Watts, CTO, Fig Leaf Software

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 19, 2011 Dec 19, 2011
LATEST

Thanks for all the replies everyone.  It was really helpful and interesting!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources