HWRF
trunk@4391
|
Contains resource usage (rusage) information that can be used with a Python "with" construct to collect the resources utilized by a block of code, or group of subprocesses executing during that block. More...
Contains resource usage (rusage) information that can be used with a Python "with" construct to collect the resources utilized by a block of code, or group of subprocesses executing during that block.
Example:
Just after the "with" block exits, the resource usage is printed to the given logger. The information can be retained for inspection instead:
Note that the logger is optional: without it, nothing is logged.
Public Member Functions | |
def | __init__ |
Creates an RUsage object for input to a "with" statement. More... | |
def | who (self) |
The "who" parameter to the constructor, which selects whether the usage measured should be of the child processes (RUSAGE_CHILDREN) or this process (RUSAGE_SELF) . More... | |
def | pagesize (self) |
System page size in bytes from resource.getpagesize(). More... | |
def | __enter__ (self) |
Gets the resource usage and time at the top of the "with" block. More... | |
def | __exit__ (self, type, value, tb) |
Gets the resource usage and time at the end of a "with" block. More... | |
def | report (self) |
Generates a string report of the resource usage utilized. More... | |
def | __str__ (self) |
Generates a string report of the resource usage utilized. More... | |
Public Attributes | |
logger | |
The logging.Logger for log messages. | |
rusage_before | |
Resource usage before monitoring began. | |
rusage_after | |
The resource usage after monitoring ended. | |
time_before | |
The current time before usage monitoring began. | |
time_after | |
The current time after monitoring ended. More... | |
def produtil.rusage.RUsage.__init__ | ( | self, | |
who = resource.RUSAGE_CHILDREN , |
|||
logger = None |
|||
) |
def produtil.rusage.RUsage.__enter__ | ( | self | ) |
def produtil.rusage.RUsage.__exit__ | ( | self, | |
type, | |||
value, | |||
tb | |||
) |
def produtil.rusage.RUsage.__str__ | ( | self | ) |
def produtil.rusage.RUsage.pagesize | ( | self | ) |
def produtil.rusage.RUsage.report | ( | self | ) |
Generates a string report of the resource usage utilized.
Accessible via str(self).
Definition at line 261 of file rusage.py.
Referenced by produtil.rusage.RUsage.__exit__(), and produtil.rusage.RUsage.__str__().
def produtil.rusage.RUsage.who | ( | self | ) |
produtil.rusage.RUsage.time_after |
The current time after monitoring ended.
Definition at line 214 of file rusage.py.
Referenced by produtil.rusage.RUsage.__exit__(), and produtil.rusage.RUsage.report().