pydecorium.decorators.Memory#

To use the Memory decorator, refer to the documentation Memory Usage.

class pydecorium.decorators.Memory(*args, **kwargs)[source]#

Timer Memory is a decorator that measures the memory usage of a function.

The Memory class is a subclass of the pydecorium.decorators.ProfilerUtils base class.

The data_name attribute is set to “memory usage”.

Note

The memory handle result is given in bytes. It can be summed to get the total memory usage. The string_value method converts the result in bytes, kilobytes, megabytes.

handle_result() int[source]#

Computes the memory usage.

Returns:

The memory usage in bytes.

Return type:

int

post_execute(func, *args, **kwargs) None[source]#

Computes the memory usage after the function execution.

pre_execute(func, *args, **kwargs) None[source]#

Computes the memory usage before the function execution.

string_value(result) str[source]#

Converts the memory usage in bytes, kilobytes, megabytes in the format “{megabytes}MB {kilobytes}KB {bytes}B”.

Parameters:

result (int) – The memory usage in bytes.

Returns:

The memory usage in bytes, kilobytes, megabytes.

Return type:

str

Raises:

TypeError – If the parameter result is not an integer.