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. |