Skip to content

Commit

Permalink
Capture class information for special class functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tgerdesnv authored and dzier committed Jul 25, 2020
1 parent a0009e8 commit 8b91cb0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pyprof/nvtx/nvmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,28 @@ def get_trace_info(op_name):
#
fn_name = frame.name

# Capture class name for any special class functions
#
if (frame.name.startswith("__")):

# Iterate through the stack frames (like a linked list) until we get
# to the detailed frame we want. This is much faster and less
# expensive than extracting the entire frame stack every time
#
# ins stack is backwards from traceback, so depth is inverse
# of current traceback depth
#
depth = len(stack) - i
ins_frame = ins.currentframe()
for _ in range(1,depth):
ins_frame = ins_frame.f_back

# Grab the class name if it exists
#
if 'self' in ins_frame.f_locals:
fn_name = ins_frame.f_locals['self'].__class__.__name__ + "::" + fn_name


key = (func_stack, frame.name)

if key not in func_map.keys():
Expand Down

0 comments on commit 8b91cb0

Please sign in to comment.