Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Dprof and main::BEGIN

by broquaint (Abbot)
on Nov 29, 2002 at 14:25 UTC ( #216529=note: print w/replies, xml ) Need Help??


in reply to Dprof and main::BEGIN

I am seeing that the majority of time (40% or more) is being taken up with many thousands of calls to main::BEGIN.
The answer can be found in a recent p5p post by Tim Bunce
A BEGIN block gets a CV, executes, the CV is freed and another sub is created with the same CV address. The result is that Devel::DProf (for example) will report BEGIN blocks being called many times when in fact it's a different sub. Very frustrating.
The initial p5p thread starts here.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Dprof and main::BEGIN
by dbush (Deacon) on Nov 29, 2002 at 15:48 UTC

    broquaint many thanks for your response.

    From the sounds of things, this effect is unavoidable. Just to clarify my understanding, is a CV an internal data structure? I seem to remember reading something in perlman:perlguts about two letter typedefs before I was scared away.

    Regards,
    Dom.

      Just to clarify my understanding, is a CV an internal data structure?
      A CV is an internal representation of a subroutine (see. Code Value). It's a typedef of a struct cv which has a pointer to a XPVCV which is a typedef for a struct xpvcv which can be found in cv.h in the perl source code. Simple as that ;)
      HTH

      _________
      broquaint

        Many thanks to broquaint and Elian for their answers. ++ to you both. I had a brief look at cv.h but the fear overcame me again.

        Regards,
        Dom

      CV is short for Code Value, and is one of perl's internal data types. (It's a sub-class of SV, the Scalar Value, if you can think of purely C code as subclassing anything :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://216529]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-05-18 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (70 votes). Check out past polls.

    Notices?