in reply to Convenient way to track function calls?

If you want to be clever you can go through the symbol table something like this
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; }; } } }
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 :)

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
    That looks remarkably similar to the highly-underappreciated Devel::TraceMethods. The clever mirod has a similar idea. Of course, the named module works on any package, allows more flexible logging, and doesn't whack typeglob slots.

    Not that I'm bragging. :)