pylops_mpi.utils.benchmark#

pylops_mpi.utils.benchmark(func=None, description='', logger=None)[source]#

A wrapper for code injection for time measurement.

This wrapper measures the start-to-end time of the wrapped function when decorated without any argument.

It also allows users to put a call to mark() anywhere inside the wrapped function for fine-grain time benchmark. This wrapper defines the local_mark() and pushes it to the _mark_func_stack for isolation in case of nested call. The user-facing mark() will always call the function at the top of the _mark_func_stack.

Parameters:
funccallable, optional

Function to be decorated. Defaults to None.

descriptionstr, optional

Description for the output text. Defaults to ''.

logger: :obj:`logging.Logger`, optional

A logging.Logger object for logging the benchmark text output. This logger must be setup before passing to this function to either writing output to a file or log to stdout. If logger is not provided, the output is printed to stdout.

Examples using pylops_mpi.utils.benchmark#

Benchmark Utility in PyLops-MPI

Benchmark Utility in PyLops-MPI