in reply to Convenient way to track function calls?
You can also do fun things like time each call, etc... but this example only works on things in the main symbol table, and there is danger of infinate loop if you call a subroutine for each call (make sure you don't install the trace in the subroutine you call :)inst_trace(); foo(); bar('test'); sub foo { print "Hello "; } sub bar { print "world @_\n"; } sub inst_trace { for(keys %{*::}) { if(*{$_}{CODE}) { my $sub = $_; my $ref = \&{$sub}; *{$sub} = sub { print STDERR "$sub called\n"; &$ref; }; } } }
Probably a much better idea is to look at Devel::Dprof is your friend by Ovid, which probably does what you want, including showing you a nice call tree, and identifying the subroutines taking the most of your time...
- Ant
- Some of my best work - Fish Dinner
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Convenient way to track function calls?
by chromatic (Archbishop) on Aug 30, 2001 at 00:56 UTC |