profiling#


profiled(func: Optional[Callable] = None, *, sampling_interval_seconds: Optional[float] = None, print_to_console=True, log_to_file=False, file_name: Optional[str] = None)[source]#

Function decorator for profiling the annotated/given function with the pyinstrument profiler

Parameters:
  • func – the function to be profiled

  • sampling_interval_seconds – sampling every <sampling_interval_seconds> seconds, if None use default parameter of pyinstrument profiler

  • print_to_console – if, true print profiler output to console

  • log_to_file – if true, logs profiler output to html file

  • file_name – optional file name for log, if None defaults to file name derived from function name

Returns:

the wrapped function

timed(func)[source]#

Function decorator which logs execution times of the wrapped/annotated function at INFO level :param func: the function whose execution time to log :return: the wrapped function