I'm having a hard time tracking down unnecessary redundant calls within a rather complex algorithm.
It looks like (some of my) my algorithm(s) is/are seriously slowed down by redundant calls (in several subroutines) of a non-cached and comparatively expensive function. To confirm this I'd like to utilize Dtrace to detect multiple calls of a single function within a given branch of the call stack tree.
I'd like to be able to ask dtrace to:
search the call stack tree within a given function (here
"foo();"
, see attached image) for duplicate function calls ("c();"
, e.g.)log them with their respective call count (here: 3x for
"c();"
)
and if possible also
- log the call stacks of each occurrence (
"foo()/a()/c()"
,"foo()/a()/b()/c()"
,"foo()/a()/b()/d()/c()"
).
Is this possible? And if yes, any idea how?
Thanks in advance!
Note: I used C in my sample code even though my code is actually in Objective-C, but this kind of thing should be kind of language-agnostic, shouldn't it? The general approach/idea at least.