@@ -126,23 +126,30 @@ codespell: ## Run codespell to fix common misspellings in text files
126
126
semgrep : # # Run semgrep to find bugs and enforce code standards
127
127
$(venv_dev ) /semgrep scan --config=auto
128
128
129
+ profiling-% : SLEEP = 3
130
+ profiling-% : TIMES = 30
131
+ profiling-% : OUT_DIR = docs/_static
132
+
133
+ define DISPLAY-BANNER
134
+ @echo "Start Glances for $(TIMES ) iterations (more or less 1 mins, please do not exit !)"
135
+ sleep $(SLEEP )
136
+ endef
137
+
138
+ profiling-gprof : CPROF = glances.cprof
129
139
profiling-gprof : # # Callgraph profiling (need "apt install graphviz")
130
- @echo " Start Glances for 30 iterations (more or less 1 mins, please do not exit !)"
131
- sleep 3
132
- $(PYTHON ) -m cProfile -o ./glances.cprof ./run.py --stop-after 30
133
- $(venv_dev ) /gprof2dot -f pstats ./glances.cprof | dot -Tsvg -o ./docs/_static/glances-cgraph.svg
134
- rm -f ./glances.cprof
140
+ $(DISPLAY-BANNER )
141
+ $(PYTHON ) -m cProfile -o $(CPROF ) run.py --stop-after $(TIMES )
142
+ $(venv_dev ) /gprof2dot -f pstats $(CPROF ) | dot -Tsvg -o $(OUT_DIR ) /glances-cgraph.svg
143
+ rm -f $(CPROF )
135
144
136
145
profiling-pyinstrument : # # PyInstrument profiling
137
- @echo " Start Glances for 30 iterations (more or less 1 mins, please do not exit !)"
138
- sleep 3
146
+ $(DISPLAY-BANNER )
139
147
$(PIP ) install pyinstrument
140
- $(PYTHON ) -m pyinstrument -r html -o ./docs/_static/ glances-pyinstrument.html -m glances --stop-after 30
148
+ $(PYTHON ) -m pyinstrument -r html -o $( OUT_DIR ) / glances-pyinstrument.html -m glances --stop-after $( TIMES )
141
149
142
150
profiling-pyspy : # # Flame profiling (currently not compatible with Python 3.12)
143
- @echo " Start Glances for 30 iterations (more or less 1 mins, please do not exit !)"
144
- sleep 3
145
- $(venv_dev ) /py-spy record -o ./docs/_static/glances-flame.svg -d 60 -s -- $(PYTHON ) ./run.py --stop-after 30
151
+ $(DISPLAY-BANNER )
152
+ $(venv_dev ) /py-spy record -o $(OUT_DIR ) /glances-flame.svg -d 60 -s -- $(PYTHON ) run.py --stop-after $(TIMES )
146
153
147
154
profiling : profiling-gprof profiling-pyinstrument profiling-pyspy # # Profiling of the Glances software
148
155
@@ -153,17 +160,19 @@ trace-malloc: ## Trace the malloc() calls
153
160
memory-leak : # # Profile memory leaks
154
161
$(PYTHON ) -m glances -C $(CONF ) --memory-leak
155
162
163
+ memory-profiling : TIMES = 2400
164
+ memory-profiling : PROFILE = mprofile_* .dat
156
165
memory-profiling : # # Profile memory usage
157
166
@echo " It's a very long test (~4 hours)..."
158
- rm -f mprofile_ * .dat
167
+ rm -f $( PROFILE )
159
168
@echo " 1/2 - Start memory profiling with the history option enable"
160
- $(venv_dev ) /mprof run -T 1 -C run.py -C $(CONF ) --stop-after 2400 --quiet
161
- $(venv_dev ) /mprof plot --output ./docs/_static /glances-memory-profiling-with-history.png
162
- rm -f mprofile_ * .dat
169
+ $(venv_dev ) /mprof run -T 1 -C run.py -C $(CONF ) --stop-after $( TIMES ) --quiet
170
+ $(venv_dev ) /mprof plot --output $( OUT_DIR ) /glances-memory-profiling-with-history.png
171
+ rm -f $( PROFILE )
163
172
@echo " 2/2 - Start memory profiling with the history option disable"
164
- $(venv_dev ) /mprof run -T 1 -C run.py -C $(CONF ) --disable-history --stop-after 2400 --quiet
165
- $(venv_dev ) /mprof plot --output ./docs/_static /glances-memory-profiling-without-history.png
166
- rm -f mprofile_ * .dat
173
+ $(venv_dev ) /mprof run -T 1 -C run.py -C $(CONF ) --disable-history --stop-after $( TIMES ) --quiet
174
+ $(venv_dev ) /mprof plot --output $( OUT_DIR ) /glances-memory-profiling-without-history.png
175
+ rm -f $( PROFILE )
167
176
168
177
# Trivy installation: https://aquasecurity.github.io/trivy/latest/getting-started/installation/
169
178
trivy : # # Run Trivy to find vulnerabilities in container images
0 commit comments