measures peak cpu memory consumption of a given `function`
measures peak cpu memory consumption of a given `function`
running the function for at least interval seconds
running the function for at least interval seconds
and at most 20 * interval seconds.
and at most 20 * interval seconds.
This function is heavily inspired by: `memory_usage`
This function is heavily inspired by: `memory_usage`
of the package `memory_profiler`: https://github.com/pythonprofilers/memory_profiler/blob/895c4ac7a08020d66ae001e24067da6dcea42451/memory_profiler.py#L239
of the package `memory_profiler`: https://github.com/pythonprofilers/memory_profiler/blob/895c4ac7a08020d66ae001e24067da6dcea42451/memory_profiler.py#L239
Args:
Args:
- `function`: (`callable`): function() -> ...
- `function`: (`callable`): function() -> ...
function without any arguments to measure for which to measure the peak memory
function without any arguments to measure for which to measure the peak memory
- `interval`: (`float`, `optional`, defaults to `0.5`)
- `interval`: (`float`, `optional`, defaults to `0.5`)
interval in second for which to measure the memory usage
interval in second for which to measure the memory usage
- `device_idx`: (`int`, `optional`, defaults to `None`)
- `device_idx`: (`int`, `optional`, defaults to `None`)
device id for which to measure gpu usage
device id for which to measure gpu usage
Returns:
Returns:
- `max_memory`: (`int`)
- `max_memory`: (`int`)
cosumed memory peak in Bytes
cosumed memory peak in Bytes
"""
"""
defget_cpu_memory(process_id:int)->int:
defget_cpu_memory(process_id:int)->int:
"""
"""
measures current cpu memory usage of a given `process_id`
measures current cpu memory usage of a given `process_id`