meonkeys has asked for the wisdom of the Perl Monks concerning the following question:

Devel::DProf seems to be behaving strangely under 'use strict'.
package Foo; sub bar {} sub zap {} package main; Foo::bar(); Foo::bar(); Foo::zap(); Foo::zap();
Profiling gives...
[adamm@twins adamm]$ perl -d:DProf test.pl [adamm@twins adamm]$ dprofpp tmon.out Total Elapsed Time = 0.009968 Seconds User+System Time = 0.019968 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 0.00 0.000 -0.000 2 0.0000 - Foo::bar 0.00 0.000 -0.000 2 0.0000 - Foo::zap
Ok, that all looks peachy. Now, try turning on 'use strict' in package Foo. Code becomes...
package Foo; use strict; sub bar {} sub zap {} package main; Foo::bar(); Foo::bar(); Foo::zap(); Foo::zap();
Profiling now shows:
[adamm@mustafa adamm]$ perl -d:DProf test.pl [adamm@mustafa adamm]$ dprofpp tmon.out Total Elapsed Time = 0.019937 Seconds User+System Time = 0.019944 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 0.00 0.000 -0.000 3 0.0000 - Foo::BEGIN 0.00 0.000 -0.000 1 0.0000 - strict::import 0.00 0.000 -0.000 1 0.0000 - strict::bits 0.00 0.000 -0.000 2 0.0000 - Foo::zap
Why are there supposedly 3 calls to Foo::BEGIN()? Might this be a bug?

---
"A Jedi uses the Force for knowledge and defense, never for attack."

Replies are listed 'Best First'.
Re: possible bug in Devel::DProf code profiling under 'use strict'
by chromatic (Archbishop) on Oct 02, 2003 at 19:42 UTC
    perl -MO=Deparse 'use strict'

    If you're using a sufficiently new version of B::Deparse, you may not see that use becomes BEGIN { require MODULE; MODULE->import() };.

    I don't know where the other two calls come from.