Line-by-line memory usage of a Python program
fseoane.net
fseoane.net
C:\>ps
'ps' is not recognized as an internal or external command,
operable program or batch file.
The guy why suggested using the psutil is onto something -- definitely a 3rd-party dependency, but rolls all the platform specific messiness into a library. And much faster and less fragile than forking a new process. def makedumper(filen):
def dumpfunc(func):
with open(filen, 'a') as f:
file.write("\n\n{}".format(func.func_code))
return dumpfunc
#then to use it:
dump = makedumper("sourcefile")
dump(func1)
dump(func2)