|
From: <aye...@us...> - 2009-06-28 14:56:23
|
Revision: 4540
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4540&view=rev
Author: ayenderahien
Date: 2009-06-28 13:57:21 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Merging from 2.1.x - rest of commit
More fixes for NH 1850
Will now also report timing for batched statements execution
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs
trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs
trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs
trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs
Property Changed:
----------------
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/
Modified: trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539)
+++ trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540)
@@ -397,7 +397,7 @@
InvalidateBatchCommand();
try
{
- DoExecuteBatch(ps);
+ ExecuteBatchWithTiming(ps);
}
finally
{
@@ -406,12 +406,27 @@
}
}
+ protected void ExecuteBatchWithTiming(IDbCommand ps)
+ {
+ Stopwatch duration = null;
+ if (log.IsDebugEnabled)
+ duration = Stopwatch.StartNew();
+ var countBeforeExecutingBatch = CountOfStatementsInCurrentBatch;
+ DoExecuteBatch(ps);
+ if (log.IsDebugEnabled && duration != null)
+ log.DebugFormat("ExecuteBatch for {0} statements took {1} ms",
+ countBeforeExecutingBatch,
+ duration.ElapsedMilliseconds);
+ }
+
/// <summary>
///
/// </summary>
/// <param name="ps"></param>
protected abstract void DoExecuteBatch(IDbCommand ps);
+ protected abstract int CountOfStatementsInCurrentBatch { get; }
+
/// <summary>
/// Gets or sets the size of the batch, this can change dynamically by
/// calling the session's SetBatchSize.
Modified: trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539)
+++ trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540)
@@ -9,7 +9,7 @@
/// An implementation of the <see cref="IBatcher" />
/// interface that does no batching.
/// </summary>
- internal class NonBatchingBatcher : AbstractBatcher
+ public class NonBatchingBatcher : AbstractBatcher
{
/// <summary>
/// Initializes a new instance of the <see cref="NonBatchingBatcher"/> class.
@@ -50,7 +50,12 @@
{
}
+ protected override int CountOfStatementsInCurrentBatch
+ {
+ get { return 1; }
+ }
+
public override int BatchSize
{
get { return 1; }
Modified: trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539)
+++ trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540)
@@ -72,7 +72,7 @@
if (countOfCommands >= batchSize)
{
- DoExecuteBatch(currentBatch);
+ ExecuteBatchWithTiming(currentBatch);
}
}
@@ -108,6 +108,11 @@
}
}
+ protected override int CountOfStatementsInCurrentBatch
+ {
+ get { return countOfCommands; }
+ }
+
private void SetObjectParam(Object obj, string paramName, object paramValue)
{
System.Type objType = obj.GetType();
Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539)
+++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540)
@@ -4,10 +4,12 @@
namespace NHibernate.AdoNet
{
+ using System;
+
/// <summary>
/// Summary description for SqlClientBatchingBatcher.
/// </summary>
- internal class SqlClientBatchingBatcher : AbstractBatcher
+ public class SqlClientBatchingBatcher : AbstractBatcher
{
private int batchSize;
private int totalExpectedRowsAffected;
@@ -32,6 +34,11 @@
set { batchSize = value; }
}
+ protected override int CountOfStatementsInCurrentBatch
+ {
+ get { return currentBatch.CountOfCommands; }
+ }
+
public override void AddToBatch(IExpectation expectation)
{
totalExpectedRowsAffected += expectation.ExpectedRowCount;
@@ -39,7 +46,7 @@
string lineWithParameters = null;
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
- if (sqlStatementLogger.IsDebugEnabled)
+ if (sqlStatementLogger.IsDebugEnabled || log.IsDebugEnabled)
{
lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate);
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
@@ -57,13 +64,13 @@
if (currentBatch.CountOfCommands >= batchSize)
{
- DoExecuteBatch(batchUpdate);
+ ExecuteBatchWithTiming(batchUpdate);
}
}
protected override void DoExecuteBatch(IDbCommand ps)
{
- log.Debug("Executing batch");
+ log.DebugFormat("Executing batch");
CheckReaders();
Prepare(currentBatch.BatchCommand);
if (Factory.Settings.SqlStatementLogger.IsDebugEnabled)
Property changes on: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests:4507-4508,4510-4513
+ /branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests:4507-4508,4510-4513,4537-4538
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|