mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-06-15 08:25:07 -04:00
Add perf marks for query execution (#22082)
This commit is contained in:
@@ -19,6 +19,7 @@ import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as perf from 'vs/base/common/performance';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { IGridDataProvider, getResultsString, getTableHeaderString } from 'sql/workbench/services/query/common/gridDataProvider';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
@@ -243,6 +244,9 @@ export default class QueryRunner extends Disposable {
|
||||
// this also isn't exact but its the best we can do
|
||||
this._queryEndTime = new Date();
|
||||
|
||||
perf.mark(`sql/query/${this.uri}/handleQueryComplete`);
|
||||
this.logPerfMarks();
|
||||
|
||||
// Store the batch sets we got back as a source of "truth"
|
||||
this._isExecuting = false;
|
||||
this._hasCompleted = true;
|
||||
@@ -513,6 +517,25 @@ export default class QueryRunner extends Disposable {
|
||||
};
|
||||
this._onVisualize.fire(result);
|
||||
}
|
||||
|
||||
private logPerfMarks(): void {
|
||||
let marks = perf.getMarks().filter(mark => mark.name.startsWith(`sql/query/${this.uri}`));
|
||||
// One query editor can have one set of marks for each query gets executed,
|
||||
// we only log the latest set of marks for the latest query.
|
||||
let reverseIdx = marks.slice().reverse().findIndex(m => m.name.startsWith(`sql/query/${this.uri}/runQuery`));
|
||||
marks = marks.slice(-(reverseIdx + 1));
|
||||
let head = `Name\tTimestamp\tDelta\tTotal\n`;
|
||||
let traceMsg = '';
|
||||
let lastStartTime = -1;
|
||||
let total = 0;
|
||||
for (const { name, startTime } of marks) {
|
||||
let delta = lastStartTime !== -1 ? startTime - lastStartTime : 0;
|
||||
total += delta;
|
||||
traceMsg += `${name}\t${startTime}\t${delta}\t${total}\n`;
|
||||
lastStartTime = startTime;
|
||||
}
|
||||
this.logService.debug(`Traces for sql/query/${this.uri}:\n${head}${traceMsg}`);
|
||||
}
|
||||
}
|
||||
|
||||
export class QueryGridDataProvider implements IGridDataProvider {
|
||||
|
||||
Reference in New Issue
Block a user