I have been getting wierd results from dprofpp involving BEGIN blocks. I get an inordinately high number of call to BEGIN and I don't understand why. I have distilled the problem down to a simple example:
file 1 (T.pm):
package T;
use strict;
sub foo {
}
1;
file2 (U.pm):
package U;
use T;
sub foo {
T->foo;
}
1;
file 3 (t.pl):
#!/usr/local/bin/perl
use strict;
use U;
U->foo() foreach (0..10000);
When I run t.pl with
perl -d:DProf t.pl and then run it though
dprofpp tmon.out I get the following results:
Total Elapsed Time = -0.04006 Seconds
User+System Time = 0 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
0.00 0.040 0.005 10002 0.0000 0.0000 U::BEGIN
0.00 0.010 -0.005 10001 0.0000 - T::foo
0.00 0.000 -0.000 2 0.0000 - main::BEGIN
0.00 0.000 -0.000 2 0.0000 - strict::import
0.00 0.000 -0.000 2 0.0000 - strict::bits
0.00 0.000 -0.000 1 0.0000 - T::BEGIN
It appears that I get a BEGIN call in U every time I call a method in T. That doesn't sound right. I also changed the example to use straight function calls instead of class methods and I get the same results. Can anyone familiar with the internals elighten this poor friar?
-pete
"I am Jack's utter lack of disbelief"
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.