I am currently doing some performance tuning and have a question regarding the output of Dprofpp. I am seeing that the majority of time (40% or more) is being taken up with many thousands of calls to main::BEGIN.

The typical output that I'm getting looks like this:

> dprofpp Total Elapsed Time = -51.0824 Seconds User+System Time = 310.7123 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 44.8 139.2 114.05 843865 0.0000 0.0000 main::BEGIN 31.3 97.53 97.452 36407 0.0027 0.0027 DBI::st::execute 22.4 69.62 183.55 4 17.405 45.889 main::ScanBuffer Snip...

I had a super search and a look on CPAN. I found the following useful:

  • The CPAN documentation at Devel::DProf
  • Wierd dprofpp results. by dreadpiratepeter
  • The followup by dug seems to indicate that Dprof may be lying but... is it?
  • With Why is perl spending so much time in the BEGIN section? by erabus I thought I had cracked it but... I'm not sure that really answers it. I do not have a BEGIN {} block in my script.
  • One further thing that might be useful are the modules that I'm using:

    use strict; use DBI qw(:sql_types); use Data::Dumper;

    ... I mention this as I think the BEGIN block is called by AUTOLOADER when use-ing modules but I'm afraid that I'm not very clear on the details. One thought that I had was that Dprof was counting the BEGIN blocks in the imported modules but not labelling them correctly in the output. Plausible or not?

    Regards,
    Dom.


    In reply to Dprof and main::BEGIN by dbush

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.