Skip to content

Instantly share code, notes, and snippets.

@gpickin
Created December 28, 2013 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpickin/8155012 to your computer and use it in GitHub Desktop.
Save gpickin/8155012 to your computer and use it in GitHub Desktop.
Testing the "new" operator versus Traditional Component Creation
<h1>Tag - CreateObject .init()</h1>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Tag - CreateObject .init() Before">
<cfset obj = createObject("component", "inittest.main").init() />
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Tag - CreateObject .init() After">
<h1>Tag - cfobject .init()</h1>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Tag - cfobject .init() Before">
<cfobject component="inittest.main" name="obj" />
<cfset obj = obj.init() />
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Tag - cfobject .init() After">
<h1>Tag - cfinvoke .init()</h1>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Tag - inittest.main .init() Before">
<cfinvoke component="inittest.main" method="init" returnVariable="obj" />
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Tag - inittest.main .init() After">
<h1>Script - CreateObject .init()</h1>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Script - CreateObject .init() Before">
<cfscript>
obj = createObject("component", "inittest.main").init();
</cfscript>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Script - CreateObject .init() After">
<!--- Below Does not work in CF8 --->
<h1>Script - new .init()</h1>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Script - new .init() Before">
<cfscript>
obj = new inittest.main().init();
</cfscript>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Script - new .init() After">
<cfdump var="#obj#">
<h1>Tag - new .init()</h1>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# tag - new .init() Before">
<cfset obj = new inittest.main().init()>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# tag - new .init() After">
<cfdump var="#obj#">
<h1>Script - new implicit init</h1>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Script - new implicit init Before">
<cfscript>
obj = new inittest.main();
</cfscript>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# Script - new implicit init After">
<cfdump var="#obj#">
<h1>Tag - new implicit init</h1>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# tag - new implicit init Before">
<cfset obj = new inittest.main()>
<cffile action = "append" file = "#expandpath('./testing.txt')#" output = "#getTickCount()# tag - new implicit init After">
<cfdump var="#obj#">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment