Skip to content

Commit 039c5ba

Browse files
committed
calculate throughtput for baseline
1 parent d3eefca commit 039c5ba

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

codeflash/verification/parse_test_output.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,26 @@ def parse_func(file_path: Path) -> XMLParser:
4141

4242

4343
start_pattern = re.compile(r"!\$######([^:]*):([^:]*):([^:]*):([^:]*):([^:]+)######\$!")
44-
end_pattern = re.compile(r"!######([^:]*):([^:]*):([^:]*):([^:]*):([^:]+)######!")
44+
end_pattern = re.compile(r"!######([^:]*):([^:]*):([^:]*):([^:]*):([^:]+):([^:]+)######!")
4545

4646

4747
def calculate_function_throughput_from_test_results(test_results: TestResults, function_name: str) -> int:
48-
"""Calculate function throughput from TestResults by extracting stdout.
48+
"""Calculate function throughput from TestResults by extracting performance stdout.
4949
50-
A completed execution is defined as having both a start tag and matching end tag.
50+
A completed execution is defined as having both a start tag and matching end tag from performance wrappers.
5151
Start: !$######test_module:test_function:function_name:loop_index:iteration_id######$!
52-
End: !######test_module:test_function:function_name:loop_index:iteration_id######!
52+
End: !######test_module:test_function:function_name:loop_index:iteration_id:duration######!
5353
"""
54-
logger.info(test_results.perf_stdout)
5554
start_matches = start_pattern.findall(test_results.perf_stdout or "")
5655
end_matches = end_pattern.findall(test_results.perf_stdout or "")
57-
end_matches_set = set(end_matches)
56+
57+
end_matches_truncated = [end_match[:5] for end_match in end_matches]
58+
end_matches_set = set(end_matches_truncated)
5859

5960
function_throughput = 0
60-
logger.info(f"Total start matches: {len(start_matches)}, Total end matches: {len(end_matches)}")
6161
for start_match in start_matches:
6262
if start_match in end_matches_set and len(start_match) > 2 and start_match[2] == function_name:
63-
logger.info(f"Matched start-end pair for function '{function_name}': {start_match}")
6463
function_throughput += 1
65-
logger.info(f"Function '{function_name}' throughput: {function_throughput}")
66-
raise SystemExit
6764
return function_throughput
6865

6966

0 commit comments

Comments
 (0)