Skip to content

Commit bd632d0

Browse files
committed
Update tracer.py
1 parent 37f4a89 commit bd632d0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

codeflash/tracer.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ def tracer_logic(self, frame: FrameType, event: str) -> None:
254254
return
255255
code = frame.f_code
256256

257+
# Check function name first before resolving path
258+
if code.co_name in self.ignored_functions:
259+
return
260+
261+
# Now resolve file path only if we need it
257262
co_filename = code.co_filename
258263
if co_filename in self.path_cache:
259264
file_name = self.path_cache[co_filename]
@@ -262,8 +267,6 @@ def tracer_logic(self, frame: FrameType, event: str) -> None:
262267
self.path_cache[co_filename] = file_name
263268
# TODO : It currently doesn't log the last return call from the first function
264269

265-
if code.co_name in self.ignored_functions:
266-
return
267270
if not file_name.is_relative_to(self.project_root):
268271
return
269272
if not file_name.exists():
@@ -488,8 +491,9 @@ def trace_dispatch_return(self, frame: FrameType, t: int) -> int:
488491
cc = cc + 1
489492

490493
if pfn in callers:
491-
callers[pfn] = callers[pfn] + 1 # hack: gather more
492-
# stats such as the amount of time added to ct courtesy
494+
# Increment call count between these functions
495+
callers[pfn] = callers[pfn] + 1
496+
# Note: This tracks stats such as the amount of time added to ct
493497
# of this specific call, and the contribution to cc
494498
# courtesy of this call.
495499
else:

0 commit comments

Comments
 (0)