<filename>tasks/utils/profiling.py<gh_stars>0
import time

def time_func(function):
  def new_func(*args, **kwargs):
    # Start the clock.
    tic = time.process_time()
    # Execute the function and record the results.
    function_result = function(*args, **kwargs)
    # Calculate the elapsed time and add it to the function
    # attributes.
    toc = time.process_time()
    # Returned the function with the added elapsed attribute
    print("Computation time = {:.2f}ms".format(1000*(toc - tic)))
    return function_result
  return new_func
