Sean, yes that is what I meant, thanks! :)

And I also meant lines like these into each template (which is basically
just a cause of bad architecture imo). You still see these construction
very often.

<cfif NOT isDefined('session.loggedIn')>
        <cflocation url="login.cfm">
</cfif>



Micha Schopman
Software Engineer

Modern Media, Databankweg 12 M, 3821 AL  Amersfoort
Tel 033-4535377, Fax 033-4535388
KvK Amersfoort 39081679, Rabo 39.48.05.380

------------------------------------------------------------------------
------------------------------------------------------------------------
-----
Modern Media, Making You Interact Smarter. Onze oplossingen verbeteren
de interactie met uw doelgroep. 
Wilt u meer omzet, lagere kosten of een beter service niveau? Voor meer
informatie zie www.modernmedia.nl 
------------------------------------------------------------------------
------------------------------------------------------------------------
-----

-----Original Message-----
From: Sean Corfield [mailto:[EMAIL PROTECTED] 
Sent: vrijdag 11 februari 2005 22:48
To: CF-Talk
Subject: Re: Using Application.cfc has decreased performance

On Fri, 11 Feb 2005 09:46:46 +0100, Micha Schopman
<[EMAIL PROTECTED]> wrote:
> One thing people need to keep in mind, is that effectively there will
be
> no real degrade of performance. You only move logic for checking
session
> state (and people have been logged in or not) from the template
normally
> called after application.cfm, to application.cfc.

Just to clarify what I think Micha means...

If you have code in Application.cfm that says:

<cfapplication name="someapp" .../>
<cfif not structKeyExists(application,'init')>
<cflock scope="application" type="exclusive" timeout="10">
..... do a bunch of application init ...
</cflock>
</cfif>
<cfif not structKeyExists(session,'user')>
<cflock scope="application" type="exclusive" timeout="10">
..... do a bunch of session init ...
</cflock>
</cfif>
..... a bunch of variables / request setup ...

When you change this to Application.cfc you'll end up with:

<cfcomponent>
<cfset this.name = "someapp">
.....
<cffunction name="onApplicationStart">
..... do a bunch of application init ...
</cffunction>
<cffunction name="onSessionStart">
..... do a bunch of session init ...
</cffunction>
<cffunction name="onRequest">
<cfargument name="targetPage">
..... a bunch of variables / request setup ...
<cfinclude template="#targetPage#">
</cffunction>
</cfcomponent>

Note several things:
1. you no longer need to lock
2. you no longer need to test for app / session init on every request
- CF does it automatically
3. only onRequest is called on every request - onApplicationStart is
called just once per application and onSessionStart is called just
once per session.

So overall you gain performance from not having tests for app /
session but you lose performance for a function call and an include. I
think it's a small price to pay for the benefits of cleaner
initialization.
-- 
Sean A Corfield -- http://www.corfield.org/
Team Fusebox -- http://www.fusebox.org/
Breeze Me! -- http://www.corfield.org/breezeme
Got Gmail? -- I have 49, yes 49, invites to give away!

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:194686
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to