jina.logging.profile

jina.logging.profile.used_memory(unit=1073741824)[source]

Get the memory usage of the current process.

Parameters

unit (int) – unit of the memory, default in Gigabytes

Return type

float

jina.logging.profile.used_memory_readable()[source]

Get the memory usage of the current process in a human-readable format

Return type

str

Returns

jina.logging.profile.profiling(func)[source]

Decorator to mark a function for profiling. The time and memory usage will be recorded and printed.

Example:

@profiling
def foo():
    print(1)
class jina.logging.profile.TimeDict[source]

Bases: object

reset()[source]
class jina.logging.profile.TimeContext(task_name, logger=None)[source]

Bases: object

Timing a code snippet with a context manager

Parameters
  • task_name (str) – the context/message

  • logger (JinaLogger) – use existing logger or use naive print()

Example:

with TimeContext('loop'):
    do_busy()
time_attrs = ['years', 'months', 'days', 'hours', 'minutes', 'seconds']