From 1e29d6018a7c2ff1ec9c8ca19998ceb3cac33232 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Thu, 27 Apr 2023 11:28:05 +0200 Subject: [PATCH] Fixes #181009 (#181011) * Fixes #181009 * Use isMeasurement: true for boolean --- .../widget/workerBasedDocumentDiffProvider.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/vs/editor/browser/widget/workerBasedDocumentDiffProvider.ts b/src/vs/editor/browser/widget/workerBasedDocumentDiffProvider.ts index 2b9b29571b4..7c6aae2fb46 100644 --- a/src/vs/editor/browser/widget/workerBasedDocumentDiffProvider.ts +++ b/src/vs/editor/browser/widget/workerBasedDocumentDiffProvider.ts @@ -5,9 +5,11 @@ import { Emitter, Event } from 'vs/base/common/event'; import { IDisposable } from 'vs/base/common/lifecycle'; +import { StopWatch } from 'vs/base/common/stopwatch'; import { IDocumentDiff, IDocumentDiffProvider, IDocumentDiffProviderOptions } from 'vs/editor/common/diff/documentDiffProvider'; import { ITextModel } from 'vs/editor/common/model'; import { DiffAlgorithmName, IEditorWorkerService } from 'vs/editor/common/services/editorWorker'; +import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; export class WorkerBasedDocumentDiffProvider implements IDocumentDiffProvider, IDisposable { private onDidChangeEventEmitter = new Emitter(); @@ -19,6 +21,7 @@ export class WorkerBasedDocumentDiffProvider implements IDocumentDiffProvider, I constructor( options: IWorkerBasedDocumentDiffProviderOptions, @IEditorWorkerService private readonly editorWorkerService: IEditorWorkerService, + @ITelemetryService private readonly telemetryService: ITelemetryService, ) { this.setOptions(options); } @@ -32,7 +35,25 @@ export class WorkerBasedDocumentDiffProvider implements IDocumentDiffProvider, I return this.diffAlgorithm.computeDiff(original, modified, options); } + const sw = StopWatch.create(true); const result = await this.editorWorkerService.computeDiff(original.uri, modified.uri, options, this.diffAlgorithm); + const timeMs = sw.elapsed(); + + this.telemetryService.publicLog2<{ + timeMs: number; + timedOut: boolean; + }, { + owner: 'hediet'; + + timeMs: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'To understand if the new diff algorithm is slower/faster than the old one' }; + timedOut: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'To understand how often the new diff algorithm times out' }; + + comment: 'This event gives insight about the performance of the new diff algorithm.'; + }>('diffEditor.computeDiff', { + timeMs, + timedOut: result?.quitEarly ?? true, + }); + if (!result) { throw new Error('no diff result available'); }