Changeset 1974
- Timestamp:
- Oct 25, 2005, 1:15:05 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/fit_interpolate/benchmark_least_squares.py
r1972 r1974 24 24 from Numeric import allclose, array, transpose 25 25 import os 26 27 def report_memory(i): 28 pid = os.getpid() 29 a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines() 30 print i, ' ', a2[1], 31 return int(a2[1].split()[1]) 32 33 34 def showmem(): os.system("ps axm | head -1 ; ps axm | grep py | grep -v grep") 35 36 def mem_usage(pid): 26 import sys 27 28 def mem_usage(): 37 29 ''' 38 30 returns the rss. 39 31 32 RSS The total amount of physical memory used by the task, in kilo- 33 bytes, is shown here. For ELF processes used library pages are 34 counted here, for a.out processes not. 35 40 36 Only works on nix systems. 41 37 ''' 42 38 import string 43 p=os.popen('ps uwp %s'% pid)39 p=os.popen('ps uwp %s'%os.getpid()) 44 40 lines=p.readlines() 45 41 #print "lines", lines 46 42 status=p.close() 47 if status or len(lines)!=2 :43 if status or len(lines)!=2 or sys.platform == 'win32': 48 44 return None 49 45 return int(string.split(lines[1])[4]) … … 212 208 if __name__ == "__main__": 213 209 import os 214 #val = report_memory(1)215 show_me = 'ps v %d' % os.getpid()216 os.system(show_me)217 210 suite = unittest.makeSuite(Test_Least_Squares,'test') 218 211 runner = unittest.TextTestRunner(verbosity=1) 219 #runner.run(suite) 220 os.system(show_me) 221 #end = report_memory(2) 222 val = mem_usage(os.getpid()) 223 print 'val', val 212 runner.run(suite) 213 val = mem_usage() 214 print 'RSS', val
Note: See TracChangeset
for help on using the changeset viewer.