def profile(n):
def decorator_with_name(func):<EOL><INDENT>def func_wrapper(*args, **kwargs):<EOL><INDENT>with ProfileKV(n):<EOL><INDENT>return func(*args, **kwargs)<EOL><DEDENT><DEDENT>return func_wrapper<EOL><DEDENT>return decorator_with_name<EOL>
Usage:
@profile("my_func")
def my_func(): code