utils.monitor
utils.monitor(func, record_fn=None)Monitors function execution and records running time and system information.
This function takes a function func as input and outputs a wrapped function wrapped_func. wrapped_func is similar to func, except that it also records the running time of function execution and system information. When record_fn is None, wrapped_func will return a tuple, where the 1st element is the record and the 2nd element is the original returned value of func. When it’s not None, the record will be saved into the file, and only the original returned value of func will be returned.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| func | function | The original function to be wrapped. | required |
| record_fn | (str, None) | When it is None, the monitoring record will be the first returned value of wrapped_func. Otherwise, the information will be saved into a text file with the file name record_fn and only the original returned value of func will be returned. |
str |
Returns
| Name | Type | Description |
|---|---|---|
| wrapped_func | function | The wrapped function that will record running information. |