From: <dav...@us...> - 2008-11-24 19:57:04
|
Revision: 3923 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3923&view=rev Author: davybrion Date: 2008-11-24 19:56:59 +0000 (Mon, 24 Nov 2008) Log Message: ----------- minor modifications in the Action classes to make sure the StopWatch instance is only instantiated when Statistics are enabled instead of every time one of the affected actions is executed. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs Modified: trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs 2008-11-24 19:31:52 UTC (rev 3922) +++ trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs 2008-11-24 19:56:59 UTC (rev 3923) @@ -21,10 +21,11 @@ public override void Execute() { bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; - var stopWath = new Stopwatch(); + Stopwatch stopwatch = null; if (statsEnabled) { - stopWath.Start(); + stopwatch = new Stopwatch(); + stopwatch.Start(); } IPersistentCollection collection = Collection; @@ -39,8 +40,8 @@ PostRecreate(); if (statsEnabled) { - stopWath.Stop(); - Session.Factory.StatisticsImplementor.RecreateCollection(Persister.Role, stopWath.Elapsed); + stopwatch.Stop(); + Session.Factory.StatisticsImplementor.RecreateCollection(Persister.Role, stopwatch.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs 2008-11-24 19:31:52 UTC (rev 3922) +++ trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs 2008-11-24 19:56:59 UTC (rev 3923) @@ -58,10 +58,11 @@ public override void Execute() { bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; - var stopWath = new Stopwatch(); + Stopwatch stopwatch = null; if (statsEnabled) { - stopWath.Start(); + stopwatch = new Stopwatch(); + stopwatch.Start(); } PreRemove(); @@ -83,8 +84,8 @@ if (statsEnabled) { - stopWath.Stop(); - Session.Factory.StatisticsImplementor.RemoveCollection(Persister.Role, stopWath.Elapsed); + stopwatch.Stop(); + Session.Factory.StatisticsImplementor.RemoveCollection(Persister.Role, stopwatch.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs 2008-11-24 19:31:52 UTC (rev 3922) +++ trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs 2008-11-24 19:56:59 UTC (rev 3923) @@ -31,10 +31,11 @@ bool affectedByFilters = persister.IsAffectedByEnabledFilters(session); bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled; - var stopWath = new Stopwatch(); + Stopwatch stopwatch = null; if (statsEnabled) { - stopWath.Start(); + stopwatch = new Stopwatch(); + stopwatch.Start(); } PreUpdate(); @@ -82,8 +83,8 @@ if (statsEnabled) { - stopWath.Stop(); - Session.Factory.StatisticsImplementor.UpdateCollection(Persister.Role, stopWath.Elapsed); + stopwatch.Stop(); + Session.Factory.StatisticsImplementor.UpdateCollection(Persister.Role, stopwatch.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2008-11-24 19:31:52 UTC (rev 3922) +++ trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2008-11-24 19:56:59 UTC (rev 3923) @@ -36,10 +36,11 @@ object instance = Instance; bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; - var stopWath = new Stopwatch(); + Stopwatch stopwatch = null; if (statsEnabled) { - stopWath.Start(); + stopwatch = new Stopwatch(); + stopwatch.Start(); } bool veto = PreDelete(); @@ -93,8 +94,8 @@ if (statsEnabled && !veto) { - stopWath.Stop(); - Session.Factory.StatisticsImplementor.DeleteEntity(Persister.EntityName, stopWath.Elapsed); + stopwatch.Stop(); + Session.Factory.StatisticsImplementor.DeleteEntity(Persister.EntityName, stopwatch.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2008-11-24 19:31:52 UTC (rev 3922) +++ trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2008-11-24 19:56:59 UTC (rev 3923) @@ -59,10 +59,11 @@ object instance = Instance; bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; - var stopWath = new Stopwatch(); + Stopwatch stopwatch = null; if (statsEnabled) { - stopWath.Start(); + stopwatch = new Stopwatch(); + stopwatch.Start(); } bool veto = PreInsert(); @@ -94,8 +95,8 @@ PostInsert(); if (statsEnabled && !veto) { - stopWath.Stop(); - Session.Factory.StatisticsImplementor.InsertEntity(Persister.EntityName, stopWath.Elapsed); + stopwatch.Stop(); + Session.Factory.StatisticsImplementor.InsertEntity(Persister.EntityName, stopwatch.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2008-11-24 19:31:52 UTC (rev 3922) +++ trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2008-11-24 19:56:59 UTC (rev 3923) @@ -43,10 +43,11 @@ object id = Id; bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; - var stopWath = new Stopwatch(); + Stopwatch stopwatch = null; if (statsEnabled) { - stopWath.Start(); + stopwatch = new Stopwatch(); + stopwatch.Start(); } bool veto = PreInsert(); @@ -97,8 +98,8 @@ if (statsEnabled && !veto) { - stopWath.Stop(); - factory.StatisticsImplementor.InsertEntity(Persister.EntityName, stopWath.Elapsed); + stopwatch.Stop(); + factory.StatisticsImplementor.InsertEntity(Persister.EntityName, stopwatch.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-11-24 19:31:52 UTC (rev 3922) +++ trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-11-24 19:56:59 UTC (rev 3923) @@ -48,10 +48,11 @@ object instance = Instance; bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; - var stopWath = new Stopwatch(); + Stopwatch stopwatch = null; if (statsEnabled) { - stopWath.Start(); + stopwatch = new Stopwatch(); + stopwatch.Start(); } bool veto = PreUpdate(); @@ -129,8 +130,8 @@ if (statsEnabled && !veto) { - stopWath.Stop(); - factory.StatisticsImplementor.UpdateEntity(Persister.EntityName, stopWath.Elapsed); + stopwatch.Stop(); + factory.StatisticsImplementor.UpdateEntity(Persister.EntityName, stopwatch.Elapsed); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: T. T. <te...@gm...> - 2008-11-24 20:00:05
|
Davy just a quick tip Stopwatch.StartNew() will do the same, nothing major, it is even not a minor :) + stopwatch = new Stopwatch(); + stopwatch.Start(); You can use On Mon, Nov 24, 2008 at 9:57 PM, <dav...@us...> wrote: > - stopWath.Start(); > + stopwatch = new Stopwatch(); > + stopwatch.Start(); > -- Tuna Toksöz http://www.tunatoksoz.com Typos included to enhance the readers attention! |
From: Davy B. <ra...@da...> - 2008-11-25 14:54:56
|
ah ok :) On Mon, Nov 24, 2008 at 8:59 PM, Tuna Toksöz <te...@gm...> wrote: > Davy just a quick tip > > Stopwatch.StartNew() > > will do the same, nothing major, it is even not a minor :) > > + stopwatch = new Stopwatch(); > + stopwatch.Start(); > > You can use > > On Mon, Nov 24, 2008 at 9:57 PM, <dav...@us...> wrote: > >> - stopWath.Start(); >> + stopwatch = new Stopwatch(); >> + stopwatch.Start(); >> > > > > -- > Tuna Toksöz > http://www.tunatoksoz.com > > Typos included to enhance the readers attention! > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > > |