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
In reply to Re: Convenient way to track function calls?
by suaveant
in thread Convenient way to track function calls?
by mr.dunstan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |