Add unitary test for memory profiling

This commit is contained in:
nicolargo 2022-11-12 17:15:44 +01:00
parent 91b6b4aff7
commit 056e9d2940
6 changed files with 21 additions and 7 deletions

View File

@ -74,6 +74,18 @@ trace-malloc: ## Trace the malloc() calls
memory-leak: ## Profile memory leaks
./venv/bin/python -m glances -C ./conf/glances.conf --memory-leak
memory-profiling: ## Profile memory usage
@echo "It's a very long test (~4 hours)..."
rm -f mprofile_*.dat
@echo "1/2 - Start memory profiling with the history option enable"
./venv/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --stop-after 2400 --quiet
./venv/bin/mprof plot --output ./docs/_static/glances-memory-profiling-with-history.png
rm -f mprofile_*.dat
@echo "2/2 - Start memory profiling with the history option disable"
./venv/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --disable-history --stop-after 2400 --quiet
./venv/bin/mprof plot --output ./docs/_static/glances-memory-profiling-without-history.png
rm -f mprofile_*.dat
# ===================================================================
# Docs
# ===================================================================

View File

@ -10,8 +10,8 @@ refresh=2
# Does Glances should check if a newer version is available on PyPI ?
check_update=true
# History size (maximum number of values)
# Default is 3600 seconds (1 hour)
history_size=3600
# Default is 1200 values (~1h with the default refresh rate)
history_size=1200
##############################################################################
# User interface

View File

@ -6,3 +6,5 @@ flake8
autopep8
autoflake
codespell
memory-profiler
matplotlib

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -178,13 +178,13 @@ class GlancesPlugin(object):
def update_stats_history(self):
"""Update stats history."""
# Build the history
if self.get_export() and self.history_enable():
# If the plugin data is a dict, the dict's key should be used
if self.get_key() is None:
item_name = ''
else:
item_name = self.get_key()
# Build the history
if self.get_export() and self.history_enable():
for i in self.get_items_history_list():
if isinstance(self.get_export(), list):
# Stats is a list of data