diff --git a/userbenchmark/dynamo/dynamobench/_dynamo/utils.py b/userbenchmark/dynamo/dynamobench/_dynamo/utils.py index 9d8dc2a9b5..35b0ace01d 100644 --- a/userbenchmark/dynamo/dynamobench/_dynamo/utils.py +++ b/userbenchmark/dynamo/dynamobench/_dynamo/utils.py @@ -96,10 +96,14 @@ def tabulate(rows, headers): ) -def dynamo_profiled(func): +CPROFILE_ENABLED = False + + +def cprofile_wrapper(func): @wraps(func) def profile_wrapper(*args, **kwargs): - global timer_counter + global timer_counter, CPROFILE_ENABLED + CPROFILE_ENABLED = True datafn = ( func.__name__ + f"{next(timer_counter)}.profile" ) # Name the data file sensibly @@ -181,8 +185,13 @@ def print_time_report(): # phase_names record an extra record into a separate compilation timing structure, # one keyed on frame+name rather than function. # The frame is incremented outside of this function, in def increment_frame() above. + + def dynamo_timed(original_function=None, phase_name=None): def dynamo_timed_inner(func): + if CPROFILE_ENABLED: + return func + @wraps(func) def time_wrapper(*args, **kwargs): key = func.__qualname__