def METHOD_NAME(*args, **kwargs):
    profiler = cProfile.Profile()
    prev_profiler = sys.getprofile()
    sys.setprofile(None)
    try:
        t = time.time()
        profiler.enable()
        try:
            result = func(*args, **kwargs)
        finally:
            profiler.disable()
        duration = time.time() - t
    finally:
        # To be able to combine the @profile decorator with the main thread stack tracing
        sys.setprofile(prev_profiler)
    if duration < threshold_duration:
        logger.info(f'Profiled function `{func.__name__}` executed in {duration:.3f} seconds')
    else:
        stats = _get_statistics(profiler, sort_order)
        logger.info(f'Profiled results for `{func.__name__}`:\n{stats}')
    return result