mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Add a command to compute memory usage statistics
This commit is contained in:
parent
0f5d62a3f3
commit
f44c4b61e1
8 changed files with 74 additions and 1 deletions
|
@ -55,6 +55,38 @@ export function analyzerStatus(ctx: Ctx): Cmd {
|
|||
};
|
||||
}
|
||||
|
||||
export function memoryUsage(ctx: Ctx): Cmd {
|
||||
const tdcp = new class implements vscode.TextDocumentContentProvider {
|
||||
readonly uri = vscode.Uri.parse('rust-analyzer-memory://memory');
|
||||
readonly eventEmitter = new vscode.EventEmitter<vscode.Uri>();
|
||||
|
||||
provideTextDocumentContent(_uri: vscode.Uri): vscode.ProviderResult<string> {
|
||||
if (!vscode.window.activeTextEditor) return '';
|
||||
|
||||
return ctx.client.sendRequest(ra.memoryUsage, null).then((mem) => {
|
||||
return 'Per-query memory usage:\n' + mem + '\n(note: database has been cleared)';
|
||||
});
|
||||
}
|
||||
|
||||
get onDidChange(): vscode.Event<vscode.Uri> {
|
||||
return this.eventEmitter.event;
|
||||
}
|
||||
}();
|
||||
|
||||
ctx.pushCleanup(
|
||||
vscode.workspace.registerTextDocumentContentProvider(
|
||||
'rust-analyzer-memory',
|
||||
tdcp,
|
||||
),
|
||||
);
|
||||
|
||||
return async () => {
|
||||
tdcp.eventEmitter.fire(tdcp.uri);
|
||||
const document = await vscode.workspace.openTextDocument(tdcp.uri);
|
||||
return vscode.window.showTextDocument(document, vscode.ViewColumn.Two, true);
|
||||
};
|
||||
}
|
||||
|
||||
export function matchingBrace(ctx: Ctx): Cmd {
|
||||
return async () => {
|
||||
const editor = ctx.activeRustEditor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue