mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Multiple batch execution time (#664)
* fixed bug where execution time was wrong for multiple batches * fixed bug where multiple execution would show wrong execution time * simplified logic
This commit is contained in:
@@ -303,6 +303,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
|
|
||||||
await SendMessageIfExecutingMultipleTimes(SR.EE_ExecutionInfo_InitializingLoop, false);
|
await SendMessageIfExecutingMultipleTimes(SR.EE_ExecutionInfo_InitializingLoop, false);
|
||||||
|
|
||||||
|
executionStartTime = DateTime.Now;
|
||||||
|
|
||||||
while (canContinue && timesLoop > 0)
|
while (canContinue && timesLoop > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -353,7 +355,6 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
dbCommand.CommandText = BatchText;
|
dbCommand.CommandText = BatchText;
|
||||||
dbCommand.CommandType = CommandType.Text;
|
dbCommand.CommandType = CommandType.Text;
|
||||||
dbCommand.CommandTimeout = 0;
|
dbCommand.CommandTimeout = 0;
|
||||||
executionStartTime = DateTime.Now;
|
|
||||||
|
|
||||||
List<DbColumn[]> columnSchemas = null;
|
List<DbColumn[]> columnSchemas = null;
|
||||||
if (getFullColumnSchema)
|
if (getFullColumnSchema)
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||||
@@ -98,6 +103,18 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution
|
|||||||
Assert.Equal(master, connInfo.ConnectionDetails.DatabaseName);
|
Assert.Equal(master, connInfo.ConnectionDetails.DatabaseName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestBatchExecutionTime() {
|
||||||
|
var result = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||||
|
ConnectionInfo connInfo = result.ConnectionInfo;
|
||||||
|
var fileStreamFactory = MemoryFileSystem.GetFileStreamFactory();
|
||||||
|
Query query = CreateAndExecuteQuery("select * from sys.databases", connInfo, fileStreamFactory);
|
||||||
|
DateTime elapsedTime = Convert.ToDateTime(query.Batches[0].ExecutionElapsedTime);
|
||||||
|
Query mutipleQuery = CreateAndExecuteQuery("select * from sys.databases\r\nGO 15", connInfo, fileStreamFactory);
|
||||||
|
DateTime multipleElapsedTime = Convert.ToDateTime(mutipleQuery.Batches[0].ExecutionElapsedTime);
|
||||||
|
Assert.True(multipleElapsedTime > elapsedTime);
|
||||||
|
}
|
||||||
|
|
||||||
public Query CreateAndExecuteQuery(string queryText, ConnectionInfo connectionInfo, IFileStreamFactory fileStreamFactory)
|
public Query CreateAndExecuteQuery(string queryText, ConnectionInfo connectionInfo, IFileStreamFactory fileStreamFactory)
|
||||||
{
|
{
|
||||||
Query query = new Query(queryText, connectionInfo, new QueryExecutionSettings(), fileStreamFactory);
|
Query query = new Query(queryText, connectionInfo, new QueryExecutionSettings(), fileStreamFactory);
|
||||||
@@ -105,5 +122,6 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution
|
|||||||
query.ExecutionTask.Wait();
|
query.ExecutionTask.Wait();
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user