Skip to content

Commit b383d09

Browse files
committed
single tracer test
1 parent 122f920 commit b383d09

File tree

4 files changed

+14
-60
lines changed

4 files changed

+14
-60
lines changed

code_to_optimize/code_directories/simple_tracer_e2e/testbench.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

code_to_optimize/code_directories/simple_tracer_e2e/workload.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from concurrent.futures import ThreadPoolExecutor
12
def funcA(number):
23
k = 0
34
for i in range(number * 100):
@@ -8,7 +9,14 @@ def funcA(number):
89
# Use a generator expression directly in join for more efficiency
910
return " ".join(str(i) for i in range(number))
1011

12+
def test_threadpool() -> None:
13+
pool = ThreadPoolExecutor(max_workers=3)
14+
args = list(range(10, 31, 10))
15+
result = pool.map(funcA, args)
16+
17+
for r in result:
18+
print(r)
19+
1120

1221
if __name__ == "__main__":
13-
for i in range(10, 31, 10):
14-
funcA(10)
22+
test_threadpool()

tests/scripts/end_to_end_test_tracer_replay_testbench.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/scripts/end_to_end_test_utilities.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class TestConfig:
2525
expected_unit_tests: Optional[int] = None
2626
min_improvement_x: float = 0.1
2727
trace_mode: bool = False
28-
trace_load: str = "workload"
2928
coverage_expectations: list[CoverageExpectation] = field(default_factory=list)
3029

3130

@@ -185,11 +184,7 @@ def run_trace_test(cwd: pathlib.Path, config: TestConfig, expected_improvement_p
185184
# First command: Run the tracer
186185
test_root = cwd / "tests" / (config.test_framework or "")
187186
clear_directory(test_root)
188-
189-
trace_script = "workload.py" if config.trace_load == "workload" else "testbench.py"
190-
expected_traced_functions = 3 if config.trace_load == "workload" else 4
191-
192-
command = ["python", "-m", "codeflash.tracer", "-o", "codeflash.trace", trace_script]
187+
command = ["python", "-m", "codeflash.tracer", "-o", "codeflash.trace", "workload.py"]
193188
process = subprocess.Popen(
194189
command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, cwd=str(cwd), env=os.environ.copy()
195190
)
@@ -207,8 +202,8 @@ def run_trace_test(cwd: pathlib.Path, config: TestConfig, expected_improvement_p
207202
return False
208203

209204
functions_traced = re.search(r"Traced (\d+) function calls successfully and replay test created at - (.*)$", stdout)
210-
if not functions_traced or int(functions_traced.group(1)) != expected_traced_functions:
211-
logging.error(f"Expected {expected_traced_functions} traced functions")
205+
if not functions_traced or int(functions_traced.group(1)) != 3:
206+
logging.error("Expected 3 traced functions")
212207
return False
213208

214209
replay_test_path = pathlib.Path(functions_traced.group(2))
@@ -254,4 +249,4 @@ def run_with_retries(test_func, *args, **kwargs) -> bool:
254249
logging.error("Test failed after all retries")
255250
return 1
256251

257-
return 1
252+
return 1

0 commit comments

Comments
 (0)