From 5a8a42cfdd4aaff1a2bf1d90f5cd50316e3bcab2 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 3 Apr 2021 20:33:39 +0200 Subject: [PATCH] feature: add debug mode to display ram usage Signed-off-by: Stefan Dej --- src/App.vue | 32 +++++++++++++++++++++++++++++--- src/store/index.js | 1 + 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/App.vue b/src/App.vue index 5fe649ea..a22db9e9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -83,6 +83,11 @@ + {{ $t("App.SAVECONFIG") }} mdi-file-upload{{ $t("App.UploadPrint") }} @@ -170,11 +175,16 @@ export default { loaded: 0 } }, + debugModeData: { + memory: {} + }, validGcodeExtensions: validGcodeExtensions }), created () { - this.$vuetify.theme.dark = true; - this.boolNaviHeightmap = (typeof(this.config.bed_mesh) !== "undefined"); + this.$vuetify.theme.dark = true + this.boolNaviHeightmap = (typeof(this.config.bed_mesh) !== "undefined") + + if(this.debugMode) this.getMemoryUsage() }, computed: { currentPage: function() { @@ -200,6 +210,8 @@ export default { klipperVersion: state => state.printer.software_version, remoteMode: state => state.socket.remoteMode, + + debugMode: state => state.debugMode, }), ...mapGetters([ 'getTitle', @@ -380,7 +392,21 @@ export default { favicon16.href = favicon16Default favicon32.href = favicon32Default } - } + }, + getMemoryUsage() { + if ('memory' in performance) { + if ('jsHeapSizeLimit' in performance.memory) + this.debugModeData.memory.jsHeapSizeLimit = performance.memory.jsHeapSizeLimit + + if ('totalJSHeapSize' in performance.memory) + this.debugModeData.memory.totalJSHeapSize = performance.memory.totalJSHeapSize + + if ('usedJSHeapSize' in performance.memory) + this.debugModeData.memory.usedJSHeapSize = performance.memory.usedJSHeapSize + } + + setTimeout(() => { this.getMemoryUsage() }, 1000) + }, }, watch: { language(){ diff --git a/src/store/index.js b/src/store/index.js index bfb8409f..ebdb1653 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -19,6 +19,7 @@ Vue.use(VueToast); export default new Vuex.Store({ state: { packageVersion: process.env.PACKAGE_VERSION || '0.0.0', + debugMode: process.env.VUE_APP_DEBUG_MODE || false, }, modules: { socket,