dubfi.core.profile_util

Profiling and performance monitoring utilities.

Added in version 0.1.0: (initial release)

Functions

timer(f[, log])

Log duration of wall clock time of function call.

profile_fnc(fnc[, target])

Profile function and save result to file (decorator).

monitor_memory([interval, log_fn, count]) → int

Create daemon thread that logs memory usage.

_monitor_memory_thread(interval, log_fn, count) → None

Log memory usage to log_fn in infinite loop.

Module Contents

dubfi.core.profile_util.timer(f, log=log)[source]

Log duration of wall clock time of function call.

dubfi.core.profile_util.profile_fnc(fnc, target=None)[source]

Profile function and save result to file (decorator).

dubfi.core.profile_util.monitor_memory(interval: float = 10, log_fn=log.info, count: int = -1) → int[source]

Create daemon thread that logs memory usage.

Parameters:
  • interval (float) – logging interval in seconds

  • log_fn (callable) – output function, can be print or log.info or similar. This function should take one string as argument.

  • count (int, optional) – stop after this number of log message

dubfi.core.profile_util._monitor_memory_thread(interval: float, log_fn: Callable, count: int) → None[source]

Log memory usage to log_fn in infinite loop.