File size: 491 Bytes
f53c54f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/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)