sdcpp_zimage_opt / tools /measure_rss.py
HelloSun's picture
Add build/bench scripts, patches, benchmark results and model card
f53c54f verified
Raw History Blame Contribute Delete
491 Bytes
#!/usr/bin/env python3
"""Run a command and report the peak RSS (GiB) and wall time of the process tree on stderr.
usage: measure_rss.py <cmd> [args...]
Exit code is the child's exit code.
"""
import resource
import subprocess
import sys
import time
t0 = time.time()
rc = subprocess.call(sys.argv[1:])
peak_gib = resource.getrusage(resource.RUSAGE_CHILDREN).ru_maxrss / 1024 / 1024
print(f"EXIT={rc} PEAK_RSS={peak_gib:.2f} GiB WALL={time.time() - t0:.1f}s", file=sys.stderr)
sys.exit(rc)