Skip to content

Commit 4e4b1d0

Browse files
authored
Merge pull request #198 from codeflash-ai/cf-625
Faster test results analysis (CF-625)
2 parents b92bf14 + f2148e2 commit 4e4b1d0

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

codeflash/models/models.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -537,22 +537,20 @@ def report_to_tree(report: dict[TestType, dict[str, int]], title: str) -> Tree:
537537
return tree
538538

539539
def usable_runtime_data_by_test_case(self) -> dict[InvocationId, list[int]]:
540+
# Efficient single traversal, directly accumulating into a dict.
541+
by_id: dict[InvocationId, list[int]] = {}
540542
for result in self.test_results:
541-
if result.did_pass and not result.runtime:
542-
msg = (
543-
f"Ignoring test case that passed but had no runtime -> {result.id}, "
544-
f"Loop # {result.loop_index}, Test Type: {result.test_type}, "
545-
f"Verification Type: {result.verification_type}"
546-
)
547-
logger.debug(msg)
548-
549-
usable_runtimes = [
550-
(result.id, result.runtime) for result in self.test_results if result.did_pass and result.runtime
551-
]
552-
return {
553-
usable_id: [runtime[1] for runtime in usable_runtimes if runtime[0] == usable_id]
554-
for usable_id in {runtime[0] for runtime in usable_runtimes}
555-
}
543+
if result.did_pass:
544+
if result.runtime:
545+
by_id.setdefault(result.id, []).append(result.runtime)
546+
else:
547+
msg = (
548+
f"Ignoring test case that passed but had no runtime -> {result.id}, "
549+
f"Loop # {result.loop_index}, Test Type: {result.test_type}, "
550+
f"Verification Type: {result.verification_type}"
551+
)
552+
logger.debug(msg)
553+
return by_id
556554

557555
def total_passed_runtime(self) -> int:
558556
"""Calculate the sum of runtimes of all test cases that passed.

0 commit comments

Comments
 (0)