Skip to content

Commit ce0f553

Browse files
committed
increase recursion limit + more test name updates
1 parent 4edec21 commit ce0f553

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

codeflash/benchmarking/pytest_new_process_trace_benchmarks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
import pytest
1414

1515
try:
16+
# Increase recursion limit to handle recursive benchmarks with tracing overhead
17+
original_limit = sys.getrecursionlimit()
18+
sys.setrecursionlimit(max(2000, original_limit * 2))
19+
1620
codeflash_benchmark_plugin.setup(trace_file, project_root)
1721
codeflash_trace.setup(trace_file)
1822
exitcode = pytest.main(
@@ -34,6 +38,8 @@
3438
plugins=[codeflash_benchmark_plugin],
3539
) # Errors will be printed to stdout, not stderr
3640

41+
sys.setrecursionlimit(original_limit)
42+
3743
except Exception as e:
3844
print(f"Failed to collect tests: {e!s}", file=sys.stderr)
3945
exitcode = -1

tests/test_trace_benchmarks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_trace_benchmarks() -> None:
8282
# Close connection
8383
conn.close()
8484
generate_replay_test(output_file, replay_tests_dir)
85-
test_class_sort_path = replay_tests_dir/ Path("test_code_to_optimize_tests_pytest_benchmarks_test_test_benchmark_bubble_sort_example__replay_test_0.py")
85+
test_class_sort_path = replay_tests_dir/ Path("test_tests_pytest_benchmarks_test_test_benchmark_bubble_sort_example__replay_test_0.py")
8686
assert test_class_sort_path.exists()
8787
test_class_sort_code = f"""
8888
from code_to_optimize.bubble_sort_codeflash_trace import \\
@@ -142,7 +142,7 @@ def test_code_to_optimize_bubble_sort_codeflash_trace_Sorter___init___test_class
142142
"""
143143
assert test_class_sort_path.read_text("utf-8").strip()==test_class_sort_code.strip()
144144

145-
test_sort_path = replay_tests_dir / Path("test_code_to_optimize_tests_pytest_benchmarks_test_test_process_and_sort_example__replay_test_0.py")
145+
test_sort_path = replay_tests_dir / Path("test_tests_pytest_benchmarks_test_test_process_and_sort_example__replay_test_0.py")
146146
assert test_sort_path.exists()
147147
test_sort_code = f"""
148148
from code_to_optimize.bubble_sort_codeflash_trace import \\
@@ -156,13 +156,13 @@ def test_code_to_optimize_bubble_sort_codeflash_trace_Sorter___init___test_class
156156
functions = ['compute_and_sort', 'sorter']
157157
trace_file_path = r"{output_file}"
158158
159-
def test_code_to_optimize_process_and_bubble_sort_codeflash_trace_compute_and_sort():
159+
def test_code_to_optimize_process_and_bubble_sort_codeflash_trace_compute_and_sort_test_compute_and_sort():
160160
for args_pkl, kwargs_pkl in get_next_arg_and_return(trace_file=trace_file_path, benchmark_function_name="test_compute_and_sort", function_name="compute_and_sort", file_path=r"{process_and_bubble_sort_path}", num_to_get=100):
161161
args = pickle.loads(args_pkl)
162162
kwargs = pickle.loads(kwargs_pkl)
163163
ret = code_to_optimize_process_and_bubble_sort_codeflash_trace_compute_and_sort(*args, **kwargs)
164164
165-
def test_code_to_optimize_bubble_sort_codeflash_trace_sorter():
165+
def test_code_to_optimize_bubble_sort_codeflash_trace_sorter_test_no_func():
166166
for args_pkl, kwargs_pkl in get_next_arg_and_return(trace_file=trace_file_path, benchmark_function_name="test_no_func", function_name="sorter", file_path=r"{bubble_sort_path}", num_to_get=100):
167167
args = pickle.loads(args_pkl)
168168
kwargs = pickle.loads(kwargs_pkl)

0 commit comments

Comments
 (0)