in reply to My Program Stats
What you are looking for (in general, not just with regards to Perl) is called a “profiler.”
Profilers employ operating-system instrumentation hooks that are designed for this purpose. And, they try to do this while affecting the behavior of the program as little as (or, as predictably as) possible, so that the results obtained under profiling will be comparable to those without.