Update profiling

This commit is contained in:
nicolargo 2024-11-10 13:59:42 +01:00
parent f980608724
commit 42b87acb55
5 changed files with 1803 additions and 1406 deletions

View File

@ -138,7 +138,7 @@ endef
profiling-gprof: CPROF = glances.cprof
profiling-gprof: ## Callgraph profiling (need "apt install graphviz")
$(DISPLAY-BANNER)
$(PYTHON) -m cProfile -o $(CPROF) run.py --stop-after $(TIMES)
$(PYTHON) -m cProfile -o $(CPROF) run-venv.py --stop-after $(TIMES)
$(venv_dev)/gprof2dot -f pstats $(CPROF) | dot -Tsvg -o $(OUT_DIR)/glances-cgraph.svg
rm -f $(CPROF)
@ -147,9 +147,9 @@ profiling-pyinstrument: ## PyInstrument profiling
$(PIP) install pyinstrument
$(PYTHON) -m pyinstrument -r html -o $(OUT_DIR)/glances-pyinstrument.html -m glances --stop-after $(TIMES)
profiling-pyspy: ## Flame profiling (currently not compatible with Python 3.12)
profiling-pyspy: ## Flame profiling
$(DISPLAY-BANNER)
$(venv_dev)/py-spy record -o $(OUT_DIR)/glances-flame.svg -d 60 -s -- $(PYTHON) run.py --stop-after $(TIMES)
$(venv_dev)/py-spy record -o $(OUT_DIR)/glances-flame.svg -d 60 -s -- $(PYTHON) run-venv.py --stop-after $(TIMES)
profiling: profiling-gprof profiling-pyinstrument profiling-pyspy ## Profiling of the Glances software
@ -162,15 +162,16 @@ memory-leak: ## Profile memory leaks
memory-profiling: TIMES = 2400
memory-profiling: PROFILE = mprofile_*.dat
memory-profiling: OUT_DIR = docs/_static
memory-profiling: ## Profile memory usage
@echo "It's a very long test (~4 hours)..."
rm -f $(PROFILE)
@echo "1/2 - Start memory profiling with the history option enable"
$(venv_dev)/mprof run -T 1 -C run.py -C $(CONF) --stop-after $(TIMES) --quiet
$(venv_dev)/mprof run -T 1 -C run-venv.py -C $(CONF) --stop-after $(TIMES) --quiet
$(venv_dev)/mprof plot --output $(OUT_DIR)/glances-memory-profiling-with-history.png
rm -f $(PROFILE)
@echo "2/2 - Start memory profiling with the history option disable"
$(venv_dev)/mprof run -T 1 -C run.py -C $(CONF) --disable-history --stop-after $(TIMES) --quiet
$(venv_dev)/mprof run -T 1 -C run-venv.py -C $(CONF) --disable-history --stop-after $(TIMES) --quiet
$(venv_dev)/mprof plot --output $(OUT_DIR)/glances-memory-profiling-without-history.png
rm -f $(PROFILE)

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 112 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 550 KiB

File diff suppressed because one or more lines are too long

9
run-venv.py Executable file
View File

@ -0,0 +1,9 @@
#!./venv/bin/python
import re
import sys
from glances import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())