Skip to content

Commit 22560c0

Browse files
Merge pull request #171 from codeflash-ai/fix-high-speedups
Fix high speedups in some PRs created by Codeflash
2 parents c1988da + dc29c29 commit 22560c0

File tree

3 files changed

+90
-1
lines changed

3 files changed

+90
-1
lines changed

codeflash/models/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ def total_passed_runtime(self) -> int:
561561
562562
:return: The runtime in nanoseconds.
563563
"""
564+
#TODO this doesn't look at the intersection of tests of baseline and original
564565
return sum(
565566
[min(usable_runtime_data) for _, usable_runtime_data in self.usable_runtime_data_by_test_case().items()]
566567
)

codeflash/verification/equivalence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def compare_test_results(original_results: TestResults, candidate_results: TestR
7070
are_equal = False
7171
break
7272

73-
if original_test_result.test_type in {TestType.EXISTING_UNIT_TEST, TestType.CONCOLIC_COVERAGE_TEST} and (
73+
if original_test_result.test_type in {TestType.EXISTING_UNIT_TEST, TestType.CONCOLIC_COVERAGE_TEST, TestType.GENERATED_REGRESSION, TestType.REPLAY_TEST} and (
7474
cdd_test_result.did_pass != original_test_result.did_pass
7575
):
7676
are_equal = False

tests/test_comparator.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,94 @@ def test_compare_results_fn():
10091009

10101010
assert not compare_test_results(original_results, new_results_4)
10111011

1012+
new_results_5_baseline = TestResults()
1013+
new_results_5_baseline.add(
1014+
FunctionTestInvocation(
1015+
id=InvocationId(
1016+
test_module_path="test_module_path",
1017+
test_class_name="test_class_name",
1018+
test_function_name="test_function_name",
1019+
function_getting_tested="function_getting_tested",
1020+
iteration_id="0",
1021+
),
1022+
file_name=Path("file_name"),
1023+
did_pass=True,
1024+
runtime=5,
1025+
test_framework="unittest",
1026+
test_type=TestType.GENERATED_REGRESSION,
1027+
return_value=5,
1028+
timed_out=False,
1029+
loop_index=1,
1030+
)
1031+
)
1032+
1033+
new_results_5_opt = TestResults()
1034+
new_results_5_opt.add(
1035+
FunctionTestInvocation(
1036+
id=InvocationId(
1037+
test_module_path="test_module_path",
1038+
test_class_name="test_class_name",
1039+
test_function_name="test_function_name",
1040+
function_getting_tested="function_getting_tested",
1041+
iteration_id="0",
1042+
),
1043+
file_name=Path("file_name"),
1044+
did_pass=False,
1045+
runtime=5,
1046+
test_framework="unittest",
1047+
test_type=TestType.GENERATED_REGRESSION,
1048+
return_value=5,
1049+
timed_out=False,
1050+
loop_index=1,
1051+
)
1052+
)
1053+
1054+
assert not compare_test_results(new_results_5_baseline, new_results_5_opt)
1055+
1056+
new_results_6_baseline = TestResults()
1057+
new_results_6_baseline.add(
1058+
FunctionTestInvocation(
1059+
id=InvocationId(
1060+
test_module_path="test_module_path",
1061+
test_class_name="test_class_name",
1062+
test_function_name="test_function_name",
1063+
function_getting_tested="function_getting_tested",
1064+
iteration_id="0",
1065+
),
1066+
file_name=Path("file_name"),
1067+
did_pass=True,
1068+
runtime=5,
1069+
test_framework="unittest",
1070+
test_type=TestType.REPLAY_TEST,
1071+
return_value=5,
1072+
timed_out=False,
1073+
loop_index=1,
1074+
)
1075+
)
1076+
1077+
new_results_6_opt = TestResults()
1078+
new_results_6_opt.add(
1079+
FunctionTestInvocation(
1080+
id=InvocationId(
1081+
test_module_path="test_module_path",
1082+
test_class_name="test_class_name",
1083+
test_function_name="test_function_name",
1084+
function_getting_tested="function_getting_tested",
1085+
iteration_id="0",
1086+
),
1087+
file_name=Path("file_name"),
1088+
did_pass=False,
1089+
runtime=5,
1090+
test_framework="unittest",
1091+
test_type=TestType.REPLAY_TEST,
1092+
return_value=5,
1093+
timed_out=False,
1094+
loop_index=1,
1095+
)
1096+
)
1097+
1098+
assert not compare_test_results(new_results_6_baseline, new_results_6_opt)
1099+
10121100
assert not compare_test_results(TestResults(), TestResults())
10131101

10141102

0 commit comments

Comments
 (0)