in reply to Monkey patching all subs with a basic 'starting subname' message

I would like to log the start/end of each method call

So, you are trying to implement a poor man's Devel::NYTProf. Well, you could re-implement what Devel::NYTProf does, starting with its interface to the perl interpreter. Hint: Use the debugger and compiler interfaces (DB, O, B). Plan some months of work.

Or, you could simply install Devel::NYTProf and use it. With all of its fancy statistics, timing information, reporting. Plan 5 to 15 min for installation and another 5 to 15 min to learn how to use it.

Any other wisdom to be shared here (bar the obvious "don't" and "use a cpan module")?

Oh sorry, forget that Devel::NYTProf thing. Have fun doing it the hard and ugly way. Ignore that CPAN exists. And while you start doing everything from scratch, why don't you re-invent perl? You could use your own compiler for own C variant, running your own assembler and of course, your own operating system.

CPAN is Perl's strength, not its weakness.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re: Monkey patching all subs with a basic 'starting subname' message

Replies are listed 'Best First'.
Re^2: Monkey patching all subs with a basic 'starting subname' message
by Anonymous Monk on Jul 14, 2017 at 18:38 UTC

    Thanks, Alexander;

    I appreciate that I'm reinventing the wheel, and always expected that to be the case. I'm not adverse to CPAN at all, but I don't always have the luxury at $work; and was interested in thoughts on the code I posted, more for academic reasons than anything else.

    I will check out Devel::NYTProf, at least in my local dev stack -- I will say that I do not always find it easy to find the right CPAN module for the job, and I appreciate the pointer.

      I don't always have the luxury at $work

      This is never the case for code or technical reasons. It is sometimes the case for licensing and legal reasons. If so, you should go right to you manager and say, “Look, this is a 10 month project and it’s going to be of pretty low to mediocre quality in the end and not cover some parts because I couldn’t figure out how to stop the segfaults. Or we could do this for free in a half hour today–” I’m not being an a$$ or snarky remarking about the quality. If you could do it better than, or even half as well as, the solution recommended by afoken, you wouldn’t have to ask questions here. You would already know more than the rest of us about it.

      As a learning exercise, it’s terrific though.

        It's OK, it didn't live long enough to worry about. It certainly wasn't a blocker for a 10-month cycle, I just needed it short-term, to trace the flow through some code I hadn't seen before.

        99% of my needs were covered by the code I wrote, the rest was determined pretty quickly after that, the original source was reverted shortly thereafter and the debug code I wrote was stricken from the record!

        ...and then I wondered!<.p>