Skip to content

Commit b0f15bf

Browse files
committed
refactor(dev): add progress indicator for profiler
This commit introduces a progress indicator to show how far along the profiling process is. It improves visibility and helps track execution progress in real-time.
1 parent be622c4 commit b0f15bf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scripts/monitor_pid_resources.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,14 @@ def run_py_spy():
193193

194194
# Start main resources monitoring loop.
195195
pynvml.nvmlInit()
196+
monitor_start_time = time.time()
196197
end_time = time.time() + duration
197198
logs = []
198199
cpu_usages, ram_usages, gpu_usages, vram_usages = [], [], [], []
199200
while time.time() < end_time:
200201
start_time = time.time()
202+
elapsed_monitor_time = time.time() - monitor_start_time
203+
progress = (elapsed_monitor_time / duration) * 100
201204
try:
202205
cpu_usage = total_cpu_percent_with_children(pid)
203206
memory_usage = total_memory_with_children(pid)
@@ -210,7 +213,8 @@ def run_py_spy():
210213
"VRAM (MB)": vram_usage,
211214
}
212215
click.echo(
213-
f"CPU: {cpu_usage:.2f}%, RAM: {memory_usage:.2f}MB, GPU: {gpu_usage:.2f}%, VRAM: {vram_usage:.2f}MB"
216+
f"[{progress:.1f}%] CPU: {cpu_usage:.2f}%, RAM: {memory_usage:.2f}MB, "
217+
f"GPU: {gpu_usage:.2f}%, VRAM: {vram_usage:.2f}MB"
214218
)
215219
logs.append(log_entry)
216220
cpu_usages.append(cpu_usage)

0 commit comments

Comments
 (0)