From 93a4937cc431e33dc61d84c51303e9b851b303d9 Mon Sep 17 00:00:00 2001 From: somebody1234 Date: Wed, 29 Nov 2023 00:44:46 +1000 Subject: [PATCH] Add profiling shortcuts to GUI2 (#8406) - Closes #8404 # Important Notes - All relevant documentation has already been updated in #8358. - I've tested that the keyboard shortcuts send appropriate messages over the LS connection, and have confirmed that a non-error response is received, but I'm not sure that the profiling actually works. - There seem to be no entries in `~/.enso/`, nor in `~/enso/` --- app/gui2/shared/languageServer.ts | 10 ++++++++++ app/gui2/src/bindings.ts | 2 ++ app/gui2/src/components/GraphEditor.vue | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/app/gui2/shared/languageServer.ts b/app/gui2/shared/languageServer.ts index fd6fc43adeb..c5a89576d8e 100644 --- a/app/gui2/shared/languageServer.ts +++ b/app/gui2/shared/languageServer.ts @@ -380,6 +380,16 @@ export class LanguageServer extends ObservableV2 { return this.request('runtime/getComponentGroups', {}) } + /** [Documentation](https://github.com/enso-org/enso/blob/develop/docs/language-server/protocol-language-server.md#profilingstart) */ + profilingStart(memorySnapshot?: boolean): Promise { + return this.request('profiling/start', { memorySnapshot }) + } + + /** [Documentation](https://github.com/enso-org/enso/blob/develop/docs/language-server/protocol-language-server.md#profilingstop) */ + profilingStop(): Promise { + return this.request('profiling/stop', {}) + } + /** A helper function to subscribe to file updates. * Please use `ls.on('file/event')` directly if the initial `'Added'` notifications are not * needed. */ diff --git a/app/gui2/src/bindings.ts b/app/gui2/src/bindings.ts index 985edd1d498..30d531c05af 100644 --- a/app/gui2/src/bindings.ts +++ b/app/gui2/src/bindings.ts @@ -30,6 +30,8 @@ export const graphBindings = defineKeybinds('graph-editor', { deselectAll: ['Escape', 'PointerMain'], copyNode: ['Mod+C'], pasteNode: ['Mod+V'], + startProfiling: ['Mod+Alt+,'], + stopProfiling: ['Mod+Alt+.'], }) export const selectionMouseBindings = defineKeybinds('selection', { diff --git a/app/gui2/src/components/GraphEditor.vue b/app/gui2/src/components/GraphEditor.vue index 97fd9aaf021..7ac0f1a9d45 100644 --- a/app/gui2/src/components/GraphEditor.vue +++ b/app/gui2/src/components/GraphEditor.vue @@ -132,6 +132,12 @@ const graphBindingsHandler = graphBindings.handler({ redo() { projectStore.module?.undoManager.redo() }, + startProfiling() { + projectStore.lsRpcConnection.then((ls) => ls.profilingStart(true)) + }, + stopProfiling() { + projectStore.lsRpcConnection.then((ls) => ls.profilingStop()) + }, openComponentBrowser() { if (keyboardBusy()) return false if (graphNavigator.sceneMousePos != null && !componentBrowserVisible.value) {