Profile

class mosaic.profile.profile.Profiler[source]

Bases: object

The profiler controls profiling for the local runtime, including starting and stopping the profile, and starting new traces.

clear()[source]

Clear profiler.

f_call(frame)[source]

Event fired when function is called.

Parameters:

frame

f_return(frame)[source]

Event fired when function returns.

Parameters:

frame

frame_info(level=1)[source]
maybe_stop_trace()[source]
maybe_trace()[source]
start()[source]

Start profiling.

start_trace(trace_id=None, level=1)[source]

Start a new profiling trace.

Parameters:
  • trace_id (str, optional) – Optional trace_id for this trace.

  • level (int, optional) – Level at which the trace should start.

stop()[source]

Stop profiling.

stop_trace(trace_id=None, level=1)[source]

Stop a profiling trace.

property tracing

Whether or not the profiler is activated.

class mosaic.profile.profile.GlobalProfiler[source]

Bases: object

The global profiler keeps the different endpoints of the runtime in contact, so that local profiles can be consolidated into a single, global one.

append(*args, **kwargs)[source]
dump(*args, **kwargs)[source]
get_profile()[source]
load(*args, **kwargs)[source]
recv_profile(sender_id, profiler_update)[source]
send_profile()[source]
set_local()[source]
set_remote(runtime_id='monitor')[source]
start()[source]
stop()[source]
mosaic.profile.profile.skip_profile(*args, **kwargs)[source]

Skip profiling for a decorated function:

>>> @skip_profile
>>> def function_not_profiled():
>>>     pass
Parameters:

stop_trace (bool, optional) – Whether to stop the system trace, defaults to False.

mosaic.profile.profile.no_profiler(name='no_profiler', level=1, stop_trace=False)[source]

Skip profiling for a code block:

>>> with no_profiler():
>>>     pass
Parameters:

stop_trace (bool, optional) – Whether to stop the system trace, defaults to False.