96 lines
2.7 KiB
Python
Executable File
96 lines
2.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Quick memory usage comparison script
|
|
Run this to see the difference between web and native versions
|
|
"""
|
|
|
|
import subprocess
|
|
import time
|
|
|
|
def get_process_memory(process_name):
|
|
"""Get memory usage of a process in MB"""
|
|
try:
|
|
result = subprocess.run(
|
|
['ps', 'aux'],
|
|
capture_output=True,
|
|
text=True
|
|
)
|
|
|
|
total_mem = 0
|
|
count = 0
|
|
|
|
for line in result.stdout.split('\n'):
|
|
if process_name.lower() in line.lower():
|
|
parts = line.split()
|
|
if len(parts) > 5:
|
|
# RSS is in KB, convert to MB
|
|
mem_kb = float(parts[5])
|
|
total_mem += mem_kb / 1024
|
|
count += 1
|
|
|
|
return total_mem, count
|
|
except Exception as e:
|
|
return 0, 0
|
|
|
|
def main():
|
|
print("=" * 60)
|
|
print("TechDJ Memory Usage Comparison")
|
|
print("=" * 60)
|
|
print()
|
|
|
|
# Check Chrome
|
|
chrome_mem, chrome_procs = get_process_memory('chrome')
|
|
if chrome_mem > 0:
|
|
print(f"[CHROME] Chrome (Web Panel):")
|
|
print(f" Total Memory: {chrome_mem:.1f} MB")
|
|
print(f" Processes: {chrome_procs}")
|
|
print()
|
|
else:
|
|
print("[CHROME] Chrome: Not running")
|
|
print()
|
|
|
|
# Check PyQt6
|
|
qt_mem, qt_procs = get_process_memory('techdj_qt')
|
|
if qt_mem > 0:
|
|
print(f"[PYQT6] PyQt6 Native App:")
|
|
print(f" Total Memory: {qt_mem:.1f} MB")
|
|
print(f" Processes: {qt_procs}")
|
|
print()
|
|
else:
|
|
print("[PYQT6] PyQt6 Native App: Not running")
|
|
print()
|
|
|
|
# Comparison
|
|
if chrome_mem > 0 and qt_mem > 0:
|
|
savings = chrome_mem - qt_mem
|
|
percent = (savings / chrome_mem) * 100
|
|
|
|
print("=" * 60)
|
|
print("[STATS] Comparison:")
|
|
print(f" Memory Saved: {savings:.1f} MB ({percent:.1f}%)")
|
|
print()
|
|
|
|
# Visual bar chart
|
|
max_mem = max(chrome_mem, qt_mem)
|
|
chrome_bar = '#' * int((chrome_mem / max_mem) * 40)
|
|
qt_bar = '#' * int((qt_mem / max_mem) * 40)
|
|
|
|
print(" Chrome: " + chrome_bar + f" {chrome_mem:.0f}MB")
|
|
print(" PyQt6: " + qt_bar + f" {qt_mem:.0f}MB")
|
|
print()
|
|
|
|
if percent > 50:
|
|
print(f" [OK] PyQt6 uses {percent:.0f}% less memory!")
|
|
elif percent > 25:
|
|
print(f" [OK] PyQt6 uses {percent:.0f}% less memory")
|
|
else:
|
|
print(f" PyQt6 uses {percent:.0f}% less memory")
|
|
|
|
print("=" * 60)
|
|
print()
|
|
print("Tip: Run both versions and execute this script to compare!")
|
|
print()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|