def performance_function(units, *, perf_key=None):
    'Decorate a function to extract a performance variable.\n\n            The ``units`` argument indicates the units of the performance\n            variable to be extracted.\n            The ``perf_key`` optional arg will be used as the name of the\n            performance variable. If not provided, the function name will\n            be used as the performance variable name.\n            '
    if (not isinstance(units, str)):
        raise TypeError('performance units must be a string')
    if (perf_key and (not isinstance(perf_key, str))):
        raise TypeError("'perf_key' must be a string")

    def _deco_wrapper(func):
        if (not utils.is_trivially_callable(func, non_def_args=1)):
            raise TypeError(f'performance function {func.__name__!r} has more than one argument without a default value')

        @functools.wraps(func)
        def _perf_fn(*args, **kwargs):
            return _DeferredPerformanceExpression(func, units, *args, **kwargs)
        _perf_key = (perf_key if perf_key else func.__name__)
        setattr(_perf_fn, '_rfm_perf_key', _perf_key)
        return _perf_fn
    return _deco_wrapper
Decorate a function to extract a performance variable.

The ``units`` argument indicates the units of the performance
variable to be extracted.
The ``perf_key`` optional arg will be used as the name of the
performance variable. If not provided, the function name will
be used as the performance variable name.
def performance_function(units, *, perf_key=None):
    'Decorate a function to extract a performance variable.\n\n            The ``units`` argument indicates the units of the performance\n            variable to be extracted.\n            The ``perf_key`` optional arg will be used as the name of the\n            performance variable. If not provided, the function name will\n            be used as the performance variable name.\n            '
    if (not isinstance(units, str)):
        raise TypeError('performance units must be a string')
    if (perf_key and (not isinstance(perf_key, str))):
        raise TypeError("'perf_key' must be a string")

    def _deco_wrapper(func):
        if (not utils.is_trivially_callable(func, non_def_args=1)):
            raise TypeError(f'performance function {func.__name__!r} has more than one argument without a default value')

        @functools.wraps(func)
        def _perf_fn(*args, **kwargs):
            return _DeferredPerformanceExpression(func, units, *args, **kwargs)
        _perf_key = (perf_key if perf_key else func.__name__)
        setattr(_perf_fn, '_rfm_perf_key', _perf_key)
        return _perf_fn
    return _deco_wrapper