Created
December 28, 2013 01:29
-
-
Save gpickin/8155012 to your computer and use it in GitHub Desktop.
Testing the "new" operator versus Traditional Component Creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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