On 10/5/07, Brian Kotek <[EMAIL PROTECTED]> wrote: > True CF8 object creation is way, way faster (hooray!). But even on CF8, > creating per-request objects with ColdSpring is always going to be a tiny > bit slower than creating them with your own factory, due to ColdSpring > resolving the dependencies.
CF8 can create 1000 simple objects in about 100ms on my laptop. Creating them via ColdSpring takes about 4800ms so I'm not sure I'd class that as "a tiny bit slower"... If you're only creating one or two transients per request with ColdSpring then it's a small per-request overhead. FWIW, the overhead of duplicate() is close to ColdSpring/LightWire: Simple Create: 62ms Simple Duplicate: 3814ms Create/Init: 96ms Duplicate/Init: 3985ms Create CS Factory: 64ms CS Create First Bean: 16ms CS Create Without First Call: 4775ms Create LW Factory: 4ms LW Create First Bean: 4ms LW Create Without First Call: 4226ms CS/LW auto-call the init() so I compared Create/Init against CS/LW. I separated out the first getBean() call since that always has more overhead. I'm pasting the code in below in case anyone wants to try it on CF7. FWIW, Trusted Cache has a *huge* impact on the numbers: Simple Create: 36ms Simple Duplicate: 83ms Create/Init: 51ms Duplicate/Init: 94ms Create CS Factory: 7ms CS Create First Bean: 11ms CS Create Without First Call: 1233ms Create LW Factory: 1ms LW Create First Bean: 0ms LW Create Without First Call: 244ms -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood <!--- simple.cfc ---> <cfcomponent output="false"> <cffunction name="init" returntype="any" access="public" output="false"> <cfset variables.x = "I'm a string" /> <cfset variables.y = 42 /> <cfreturn this /> </cffunction> <cffunction name="getX" returntype="string" access="public" output="false"> <cfreturn variables.x /> </cffunction> <cffunction name="getY" returntype="numeric" access="public" output="false"> <cfreturn variables.y /> </cffunction> </cfcomponent> <!--- coldspring.xml ---> <beans> <bean id="simple" class="speed.simple" singleton="false" /> </beans> <!--- BeanConfig.cfc ---> <cfcomponent name="LightBaseBeanConfig" extends="lightwire.BaseConfigObject" hint="A LightWire configuration bean."> <cffunction name="init" output="false" returntype="any" hint="I initialize the config bean."> <cfscript> // Call the base init() method to set sensible defaults. Do NOT remove this. Super.init(); // BEAN DEFINITIONS (see top of bean for instructions) addTransient("speed.simple"); </cfscript> <cfreturn THIS> </cffunction> </cfcomponent> <!--- create.cfm ---> <cfparam name="URL.n" default="1000" /> <cftimer label="Simple Create" type="outline"> <cfsilent> <cfloop index="i" from="1" to="#URL.n#"> <cfset obj = createObject("component","simple") /> </cfloop> </cfsilent> </cftimer> <cftimer label="Simple Duplicate" type="outline"> <cfsilent> <cfloop index="i" from="1" to="#URL.n#"> <cfset obj = duplicate(obj) /> </cfloop> </cfsilent> </cftimer> <cftimer label="Create/Init" type="outline"> <cfsilent> <cfloop index="i" from="1" to="#URL.n#"> <cfset obj = createObject("component","simple").init() /> </cfloop> </cfsilent> </cftimer> <cftimer label="Duplicate/Init" type="outline"> <cfsilent> <cfloop index="i" from="1" to="#URL.n#"> <cfset obj = duplicate(obj).init() /> </cfloop> </cfsilent> </cftimer> <cftimer label="Create CS Factory" type="outline"> <cfset cs = createObject("component","coldspring.beans.DefaultXmlBeanFactory").init() /> <cfset cs.loadBeans( "/speed/coldspring.xml" ) /> </cftimer> <cftimer label="CS Create First Bean" type="outline"> <cfset obj = cs.getBean("simple") /> </cftimer> <cftimer label="CS Create Without First Call" type="outline"> <cfsilent> <cfloop index="i" from="1" to="#URL.n#"> <cfset obj = cs.getBean("simple") /> </cfloop> </cfsilent> </cftimer> <cftimer label="Create LW Factory" type="outline"> <cfset lwcfg = createObject("component","BeanConfig").init() /> <cfset lw = createObject("component","lightwire.LightWire").init(lwcfg) /> </cftimer> <cftimer label="LW Create First Bean" type="outline"> <cfset obj = lw.getBean("simple") /> </cftimer> <cftimer label="LW Create Without First Call" type="outline"> <cfsilent> <cfloop index="i" from="1" to="#URL.n#"> <cfset obj = lw.getBean("simple") /> </cfloop> </cfsilent> </cftimer> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290374 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

