deephyper.evaluator.profile

Contents

deephyper.evaluator.profile#

deephyper.evaluator.profile(_func=None, *, memory: bool = False, memory_limit: int = -1, memory_tracing_interval: float = 0.1, raise_exception: bool = False, register=True)[source]#

Decorator to use on a run_function to profile its execution-time and peak memory usage.

It will add the m:timestamp_start, m:timestamp_end and optionaly m:memory metadata columns to the results.

By default, only the run-time is measured, for example by using the decorator as follows:

@profile
def run(config):
    ...
    return y

If the memory argument is set to True, the memory usage is also measured, for example by using the decorator as follows:

@profile(memory=True)
def run(config):
    ...
    return y

If the memory_limit is used then the call will be cancelled (when possible) if the memory usage exceeds the limit, for example by using the decorator as follows:

@profile(memory=True, memory_limit=0.1 * 1024**3, memory_tracing_interval=0.01)
def run(config):
    ...
    return y
Parameters:
  • memory (bool) – If True, the memory usage is measured. The measured memory, in bytes, accounts for the whole process. Defaults to False.

  • memory_limit (int) – In bytes, if set to a positive integer, the memory usage is measured at regular intervals and the function is interrupted if the memory usage exceeds the limit. If set to -1, only the peak memory is measured. If the executed function is busy outside of the Python interpretor, this mechanism will not work properly. Defaults to -1.

  • memory_tracing_interval (float) – In seconds, the interval at which the memory usage is measured. Defaults to 0.1.

  • register (bool) – Register the called function to be pickalable and executed in a subprocess when the we use as decorator @profile.

Returns:

a decorated function.

Return type:

function