gfw.common.decorators.timing#

timing(f, quiet=False, logger=<Logger gfw.common.decorators (WARNING)>, decimals=4)[source]#

Decorator to measure execution time of a function.

Parameters:
  • f (Callable[[...], Any]) – The function to time.

  • quiet (bool) – If true, doesn’t log the elapsed time.

  • logger (Logger) – The logger to use.

  • decimals (int) – How many decimals to use when rounding. Only used for logging.

Returns:

A wrapper around the original callable that returns a 2D tuple with:

  • Whatever the original callable returns.

  • The elapsed time.

Return type:

Callable