Skip to content

Commit d3eefca

Browse files
committed
perfstdout
1 parent 2e0f38f commit d3eefca

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

codeflash/models/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ class TestResults(BaseModel): # noqa: PLW1641
565565
# also we don't support deletion of test results elements - caution is advised
566566
test_results: list[FunctionTestInvocation] = []
567567
test_result_idx: dict[str, int] = {}
568+
perf_stdout: Optional[str] = None
568569

569570
def add(self, function_test_invocation: FunctionTestInvocation) -> None:
570571
unique_id = function_test_invocation.unique_invocation_loop_id

codeflash/optimization/function_optimizer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,6 +1810,8 @@ def run_and_parse_tests(
18101810
coverage_database_file=coverage_database_file,
18111811
coverage_config_file=coverage_config_file,
18121812
)
1813+
if testing_type == TestingMode.PERFORMANCE:
1814+
results.perf_stdout = run_result.stdout
18131815
return results, coverage_results
18141816
results, coverage_results = parse_line_profile_results(line_profiler_output_file=line_profiler_output_file)
18151817
return results, coverage_results

codeflash/verification/parse_test_output.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,9 @@ def calculate_function_throughput_from_test_results(test_results: TestResults, f
5151
Start: !$######test_module:test_function:function_name:loop_index:iteration_id######$!
5252
End: !######test_module:test_function:function_name:loop_index:iteration_id######!
5353
"""
54-
all_stdout = ""
55-
for result in test_results.test_results:
56-
if result.stdout:
57-
all_stdout += result.stdout
58-
59-
start_matches = start_pattern.findall(all_stdout)
60-
end_matches = end_pattern.findall(all_stdout)
54+
logger.info(test_results.perf_stdout)
55+
start_matches = start_pattern.findall(test_results.perf_stdout or "")
56+
end_matches = end_pattern.findall(test_results.perf_stdout or "")
6157
end_matches_set = set(end_matches)
6258

6359
function_throughput = 0
@@ -66,7 +62,8 @@ def calculate_function_throughput_from_test_results(test_results: TestResults, f
6662
if start_match in end_matches_set and len(start_match) > 2 and start_match[2] == function_name:
6763
logger.info(f"Matched start-end pair for function '{function_name}': {start_match}")
6864
function_throughput += 1
69-
65+
logger.info(f"Function '{function_name}' throughput: {function_throughput}")
66+
raise SystemExit
7067
return function_throughput
7168

7269

0 commit comments

Comments
 (0)