Created
June 16, 2017 18:58
-
-
Save mukulmishra18/18635de4c82522bde3e7c4c0761f3365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
from __future__ import print_function | |
import subprocess | |
import sys | |
import time | |
if (len(sys.argv)) != 2: | |
print("usage:", sys.argv[0], "<pid>") | |
sys.exit(1) | |
pid = sys.argv[1] | |
peak_rss = 0 | |
try: | |
while True: | |
# Use -p because --pid doesn't work on Mac. | |
# Also, have to split the output because --no-headers doesn't work on | |
# Mac. | |
cmd = ["ps", "-o", "rss", "-p", pid]; | |
heading, rss = (subprocess.check_output(cmd).rstrip()).split('\n'); | |
rss = int(rss) | |
print("{0:.2f} MiB".format(rss / 1024.0)) | |
if (rss > peak_rss): | |
peak_rss = rss | |
time.sleep(0.05) | |
except: | |
print("\npeak: {0:.2f} MiB".format(peak_rss / 1024.0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment