feat: replace logging with custom log_all function and truncate benchmark log on start

This commit is contained in:
2026-01-29 06:42:06 +00:00
parent 608b69e547
commit d0a17cd3c9
52 changed files with 11512 additions and 5041 deletions
+5 -9
View File
@@ -1,18 +1,14 @@
import psutil
import time
LOG_FILE = 'usage.log'
INTERVAL = 5 # seconds
try:
with open(LOG_FILE, 'a') as log:
with open('usage.log', 'a') as log_file:
while True:
cpu_percent = psutil.cpu_percent(interval=1)
mem = psutil.virtual_memory()
log_entry = f"CPU: {cpu_percent}%, Memory: {mem.percent}%\n"
log.write(log_entry)
log.flush()
print(log_entry.strip())
time.sleep(INTERVAL - 1)
log_file.write(log_entry)
log_file.flush()
time.sleep(4)
except KeyboardInterrupt:
print('Monitoring stopped by user.')
print("Monitoring stopped by user.")