diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs
index 10b2d9b1..14a5e2c7 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs
@@ -30,6 +30,16 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
///
private bool disposed;
+ ///
+ /// Local time when the execution and retrieval of files is finished
+ ///
+ private DateTime executionEndTime;
+
+ ///
+ /// Local time when the execution starts, specifically when the object is created
+ ///
+ private readonly DateTime executionStartTime;
+
///
/// Factory for creating readers/writers for the output of the batch
///
@@ -55,6 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
// Initialize the internal state
BatchText = batchText;
+ executionStartTime = DateTime.Now;
Selection = new SelectionData(startLine, startColumn, endLine, endColumn);
HasExecuted = false;
resultSets = new List();
@@ -69,6 +80,30 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
///
public string BatchText { get; set; }
+ ///
+ /// Localized timestamp for when the execution completed.
+ /// Stored in UTC ISO 8601 format; should be localized before displaying to any user
+ ///
+ public string ExecutionEndTimeStamp { get { return executionEndTime.ToString("o"); } }
+
+ ///
+ /// Localized timestamp for how long it took for the execution to complete
+ ///
+ public string ExecutionElapsedTime
+ {
+ get
+ {
+ TimeSpan elapsedTime = executionEndTime - executionStartTime;
+ return elapsedTime.ToString();
+ }
+ }
+
+ ///
+ /// Localized timestamp for when the execution began.
+ /// Stored in UTC ISO 8601 format; should be localized before displaying to any user
+ ///
+ public string ExecutionStartTimeStamp { get { return executionStartTime.ToString("o"); } }
+
///
/// Whether or not this batch has an error
///
@@ -218,6 +253,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
// Mark that we have executed
HasExecuted = true;
+ executionEndTime = DateTime.Now;
}
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/BatchSummary.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/BatchSummary.cs
index 7e1b2837..884d76f6 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/BatchSummary.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/BatchSummary.cs
@@ -10,6 +10,21 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
///
public class BatchSummary
{
+ ///
+ /// Localized timestamp for how long it took for the execution to complete
+ ///
+ public string ExecutionElapsed { get; set; }
+
+ ///
+ /// Localized timestamp for when the execution completed.
+ ///
+ public string ExecutionEnd { get; set; }
+
+ ///
+ /// Localized timestamp for when the execution started.
+ ///
+ public string ExecutionStart { get; set; }
+
///
/// Whether or not the batch was successful. True indicates errors, false indicates success
///
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs
index 1c48d516..61b17543 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs
@@ -132,6 +132,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
return Batches.Select((batch, index) => new BatchSummary
{
Id = index,
+ ExecutionStart = batch.ExecutionStartTimeStamp,
+ ExecutionEnd = batch.ExecutionEndTimeStamp,
+ ExecutionElapsed = batch.ExecutionElapsedTime,
HasError = batch.HasError,
Messages = batch.ResultMessages.ToArray(),
ResultSetSummaries = batch.ResultSummaries,