How can I profile a subroutine without using modules?
        Posted  
        
            by Zaid
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Zaid
        
        
        
        Published on 2010-04-25T15:00:46Z
        Indexed on 
            2010/04/25
            15:03 UTC
        
        
        Read the original article
        Hit count: 244
        
I'm tempted to relabel this question 'Look at this brick. What type of house does it belong to?'
Here's the situation: I've effectively been asked to profile some subroutines having access to neither profilers (even Devel::DProf) nor Time::HiRes. The purpose of this exercise is to 'locate' bottlenecks.
At the moment, I'm sprinkling print statements at the beginning and end of each sub that log entries and exits to file, along with the result of the time function. Not ideal, but it's the best I can go by given the circumstances. At the very least it'll allow me to see how many times each sub is called.
The code is running under Unix. The closest thing I see to my need is  perlfaq8, but that doesn't seem to help (I don't know how to make a syscall, and am wondering if it'll affect the code timing unpredictably).
Not your typical everyday SO question...
© Stack Overflow or respective owner