Improve meminfo debug formatting
This commit is contained in:
@@ -895,8 +895,8 @@ class GuiPreferences(NDialog):
|
|||||||
refreshTree = False
|
refreshTree = False
|
||||||
|
|
||||||
# Appearance
|
# Appearance
|
||||||
guiLocale = self.guiLocale.currentData()
|
guiLocale = self.guiLocale.currentData()
|
||||||
guiTheme = self.guiTheme.currentData()
|
guiTheme = self.guiTheme.currentData()
|
||||||
|
|
||||||
updateTheme |= CONFIG.guiTheme != guiTheme
|
updateTheme |= CONFIG.guiTheme != guiTheme
|
||||||
needsRestart |= CONFIG.guiLocale != guiLocale
|
needsRestart |= CONFIG.guiLocale != guiLocale
|
||||||
|
|||||||
@@ -239,9 +239,7 @@ class GuiMainStatus(QStatusBar):
|
|||||||
"""
|
"""
|
||||||
import tracemalloc
|
import tracemalloc
|
||||||
|
|
||||||
from collections import Counter
|
count = len(QApplication.allWidgets())
|
||||||
|
|
||||||
widgets = QApplication.allWidgets()
|
|
||||||
if not self._debugInfo:
|
if not self._debugInfo:
|
||||||
if tracemalloc.is_tracing():
|
if tracemalloc.is_tracing():
|
||||||
self._traceMallocRef = "Total"
|
self._traceMallocRef = "Total"
|
||||||
@@ -249,19 +247,14 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self._traceMallocRef = "Relative"
|
self._traceMallocRef = "Relative"
|
||||||
tracemalloc.start()
|
tracemalloc.start()
|
||||||
self._debugInfo = True
|
self._debugInfo = True
|
||||||
self._wCounts = Counter([type(x).__name__ for x in widgets])
|
|
||||||
|
|
||||||
if hasattr(self, "_wCounts"):
|
current, peak = tracemalloc.get_traced_memory()
|
||||||
diff = Counter([type(x).__name__ for x in widgets]) - self._wCounts
|
|
||||||
for name, count in diff.items():
|
|
||||||
logger.debug("Widget '%s': +%d", name, count)
|
|
||||||
|
|
||||||
mem = tracemalloc.get_traced_memory()
|
|
||||||
stamp = datetime.now().strftime("%H:%M:%S")
|
stamp = datetime.now().strftime("%H:%M:%S")
|
||||||
self.showMessage((
|
message = (
|
||||||
f"Debug [{stamp}]"
|
f"Widgets: {count} \u2013 "
|
||||||
f" \u2013 Widgets: {len(widgets)}"
|
f"{self._traceMallocRef} Memory: {current/1024:,.2f} kiB \u2013 "
|
||||||
f" \u2013 {self._traceMallocRef} Memory: {mem[0]:n}"
|
f"Peak: {peak/1024:,.2f} kiB"
|
||||||
f" \u2013 Peak: {mem[1]:n}"
|
)
|
||||||
), 6000)
|
self.showMessage(f"Debug [{stamp}] {message}", 6000)
|
||||||
|
logger.debug("[MEMINFO] %s", message)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user