mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-17 09:35:37 -05:00
Returning start/end and elapsed time with batch summaries (#92)
Returning start/end and elapsed timestamps for batches with the batch summary.
This commit is contained in:
@@ -30,6 +30,16 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
/// </summary>
|
||||
private bool disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Local time when the execution and retrieval of files is finished
|
||||
/// </summary>
|
||||
private DateTime executionEndTime;
|
||||
|
||||
/// <summary>
|
||||
/// Local time when the execution starts, specifically when the object is created
|
||||
/// </summary>
|
||||
private readonly DateTime executionStartTime;
|
||||
|
||||
/// <summary>
|
||||
/// Factory for creating readers/writers for the output of the batch
|
||||
/// </summary>
|
||||
@@ -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<ResultSet>();
|
||||
@@ -69,6 +80,30 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
/// </summary>
|
||||
public string BatchText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Localized timestamp for when the execution completed.
|
||||
/// Stored in UTC ISO 8601 format; should be localized before displaying to any user
|
||||
/// </summary>
|
||||
public string ExecutionEndTimeStamp { get { return executionEndTime.ToString("o"); } }
|
||||
|
||||
/// <summary>
|
||||
/// Localized timestamp for how long it took for the execution to complete
|
||||
/// </summary>
|
||||
public string ExecutionElapsedTime
|
||||
{
|
||||
get
|
||||
{
|
||||
TimeSpan elapsedTime = executionEndTime - executionStartTime;
|
||||
return elapsedTime.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Localized timestamp for when the execution began.
|
||||
/// Stored in UTC ISO 8601 format; should be localized before displaying to any user
|
||||
/// </summary>
|
||||
public string ExecutionStartTimeStamp { get { return executionStartTime.ToString("o"); } }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not this batch has an error
|
||||
/// </summary>
|
||||
@@ -218,6 +253,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
|
||||
// Mark that we have executed
|
||||
HasExecuted = true;
|
||||
executionEndTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user