Source
fd.write('#time(s) memory_virtual(Mbytes) memory_resident(Mbytes) no_filedesc CPU_user CPU_system CPU_idle CPU_wait\n')
import signal
import os
import pylab as pl
import string
import commands
import sys
import re
import time
import inspect
from tw_utils import *
from matplotlib.font_manager import FontProperties
#### usage: python profileplot.py testname RESULT_DIR \
#### webpage_abspath asciidata processname
t=[0]
y11=[0]
y22=[0]
numfile=[0]
testname=sys.argv[1]
RESULT_DIR=sys.argv[2]
webpage=sys.argv[3]
asciidata=sys.argv[4]
casapy_pid = sys.argv[5]
def handler(signum, frame):
try:
fd.close() # might not be open yet
except:
pass
a=inspect.stack()
stacklevel=0
for k in range(len(a)):
if (string.find(a[k][1], 'profileplot.py') > 0):
stacklevel=k
break
myf=sys._getframe(stacklevel).f_globals
# myf=frame.f_globals
t=myf['t']
y11=myf['y11']
y22=myf['y22']
numfile=myf['numfile']
pl.plot(t,y11,lw=2)
pl.plot(t,y22,lw=2)
if max(y11)>=max(y22):
pl.axis([0.9*min(t),1.1*max(t),0.9*min(y11),1.1*max(y11)])
else:
pl.axis([0.9*min(t),1.1*max(t),0.9*min(y22),1.1*max(y22)])
pl.xlabel('time (sec)')
pl.ylabel('memory footprint') #note virtual vs. resident
font=FontProperties(size='small')
pl.legend(('virtual','resident'),loc=[0.7,0.85], prop=font)
ax2 = pl.twinx()
pl.ylabel('No of open File Descriptors')
ax2.yaxis.tick_right()
pl.plot(t,numfile, 'r-.',lw=2)
pl.legend(['No. of Open FDs'],loc=[0.7,0.8], prop=font)
pl.title('memory usage of casapy for '+testname)
#s="test-plot.ps" change to PNG for web browser compatibility
#s="test-plot.png"