Skip to content

Commit 7aa30a8

Browse files
authored
Merge pull request #744 from codeflash-ai/codeflash/optimize-pr739-2025-09-22T19.41.32
⚡️ Speed up method `AsyncCallInstrumenter.visit_ClassDef` by 26% in PR #739 (`get-throughput-from-output`)
2 parents 654055d + 540b8aa commit 7aa30a8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

codeflash/code_utils/instrument_existing_tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ def __init__(
316316
def visit_ClassDef(self, node: ast.ClassDef) -> ast.ClassDef:
317317
# Add timeout decorator for unittest test classes if needed
318318
if self.test_framework == "unittest":
319+
timeout_decorator = ast.Call(
320+
func=ast.Name(id="timeout_decorator.timeout", ctx=ast.Load()),
321+
args=[ast.Constant(value=15)],
322+
keywords=[],
323+
)
319324
for item in node.body:
320325
if (
321326
isinstance(item, ast.FunctionDef)
@@ -327,11 +332,6 @@ def visit_ClassDef(self, node: ast.ClassDef) -> ast.ClassDef:
327332
for d in item.decorator_list
328333
)
329334
):
330-
timeout_decorator = ast.Call(
331-
func=ast.Name(id="timeout_decorator.timeout", ctx=ast.Load()),
332-
args=[ast.Constant(value=15)],
333-
keywords=[],
334-
)
335335
item.decorator_list.append(timeout_decorator)
336336
return self.generic_visit(node)
337337

0 commit comments

Comments
 (0)