提交 38e46c9a 编写于 作者: J Johannes Rieken 提交者: GitHub

duration for word based suggestions, Perf telemetry for completions #109167

上级 a6366cb0
......@@ -23,6 +23,7 @@ import { IDiffComputationResult } from 'vs/editor/common/services/editorWorkerSe
import { createMonacoBaseAPI } from 'vs/editor/common/standalone/standaloneBase';
import * as types from 'vs/base/common/types';
import { EditorWorkerHost } from 'vs/editor/common/services/editorWorkerServiceImpl';
import { StopWatch } from 'vs/base/common/stopwatch';
export interface IMirrorModel {
readonly uri: URI;
......@@ -529,13 +530,13 @@ export class EditorSimpleWorker implements IRequestHandler, IDisposable {
private static readonly _suggestionsLimit = 10000;
public async textualSuggest(modelUrl: string, position: IPosition, wordDef: string, wordDefFlags: string): Promise<string[] | null> {
public async textualSuggest(modelUrl: string, position: IPosition, wordDef: string, wordDefFlags: string): Promise<{ words: string[], duration: number } | null> {
const model = this._getModel(modelUrl);
if (!model) {
return null;
}
const sw = new StopWatch(true);
const words: string[] = [];
const seen = new Set<string>();
const wordDefRegExp = new RegExp(wordDef, wordDefFlags);
......@@ -558,7 +559,7 @@ export class EditorSimpleWorker implements IRequestHandler, IDisposable {
break;
}
}
return words;
return { words, duration: sw.elapsed() };
}
......
......@@ -161,20 +161,21 @@ class WordBasedCompletionItemProvider implements modes.CompletionItemProvider {
const insert = replace.setEndPosition(position.lineNumber, position.column);
const client = await this._workerManager.withWorker();
const words = await client.textualSuggest(model.uri, position);
if (!words) {
const data = await client.textualSuggest(model.uri, position);
if (!data) {
return undefined;
}
return {
suggestions: words.map((word): modes.CompletionItem => {
duration: data.duration,
suggestions: data.words.map((word): modes.CompletionItem => {
return {
kind: modes.CompletionItemKind.Text,
label: word,
insertText: word,
range: { insert, replace }
};
})
}),
};
}
}
......@@ -462,7 +463,7 @@ export class EditorWorkerClient extends Disposable {
});
}
public textualSuggest(resource: URI, position: IPosition): Promise<string[] | null> {
public textualSuggest(resource: URI, position: IPosition): Promise<{ words: string[], duration: number } | null> {
return this._withSyncedResources([resource]).then(proxy => {
let model = this._modelService.getModel(resource);
if (!model) {
......
......@@ -167,8 +167,9 @@ suite('EditorSimpleWorker', () => {
assert.ok(false);
return;
}
assert.equal(result.length, 1);
assert.equal(result, 'foobar');
assert.equal(result.words.length, 1);
assert.equal(typeof result.duration, 'number');
assert.equal(result.words[0], 'foobar');
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册