Filename | /usr/local/lib/perl5/5.24/constant.pm |
Statements | Executed 4623 statements in 40.6ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
148 | 148 | 33 | 23.4ms | 28.4ms | import | constant::
148 | 1 | 1 | 1.43ms | 1.43ms | CORE:subst (opcode) | constant::
148 | 1 | 1 | 1.02ms | 1.02ms | CORE:match (opcode) | constant::
148 | 1 | 1 | 945µs | 945µs | CORE:regcomp (opcode) | constant::
8 | 4 | 1 | 61µs | 61µs | __ANON__[:192] | constant::
1 | 1 | 1 | 57µs | 72µs | BEGIN@24 | constant::
1 | 1 | 1 | 44µs | 44µs | BEGIN@2 | constant::
1 | 1 | 1 | 27µs | 35µs | BEGIN@3 | constant::
1 | 1 | 1 | 26µs | 73µs | BEGIN@65 | constant::
3 | 3 | 1 | 24µs | 24µs | CORE:qr (opcode) | constant::
1 | 1 | 1 | 24µs | 636µs | BEGIN@4 | constant::
1 | 1 | 1 | 23µs | 65µs | BEGIN@141 | constant::
1 | 1 | 1 | 23µs | 92µs | BEGIN@40 | constant::
1 | 1 | 1 | 20µs | 72µs | BEGIN@90 | constant::
5 | 2 | 1 | 16µs | 16µs | _make_const (xsub) | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:174] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:190] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:41] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:42] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:43] | constant::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package constant; | ||||
2 | 2 | 107µs | 1 | 44µs | # spent 44µs within constant::BEGIN@2 which was called:
# once (44µs+0s) by Getopt::Long::BEGIN@219 at line 2 # spent 44µs making 1 call to constant::BEGIN@2 |
3 | 2 | 50µs | 2 | 44µs | # spent 35µs (27+8) within constant::BEGIN@3 which was called:
# once (27µs+8µs) by Getopt::Long::BEGIN@219 at line 3 # spent 35µs making 1 call to constant::BEGIN@3
# spent 8µs making 1 call to strict::import |
4 | 2 | 583µs | 2 | 1.25ms | # spent 636µs (24+612) within constant::BEGIN@4 which was called:
# once (24µs+612µs) by Getopt::Long::BEGIN@219 at line 4 # spent 636µs making 1 call to constant::BEGIN@4
# spent 612µs making 1 call to warnings::register::import |
5 | |||||
6 | 1 | 6µs | our $VERSION = '1.33'; | ||
7 | our %declared; | ||||
8 | |||||
9 | #======================================================================= | ||||
10 | |||||
11 | # Some names are evil choices. | ||||
12 | 1 | 17µs | my %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD }; | ||
13 | 1 | 5µs | $keywords{UNITCHECK}++ if $] > 5.009; | ||
14 | |||||
15 | 1 | 23µs | my %forced_into_main = map +($_, 1), | ||
16 | qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG }; | ||||
17 | |||||
18 | 1 | 24µs | my %forbidden = (%keywords, %forced_into_main); | ||
19 | |||||
20 | 1 | 27µs | 1 | 11µs | my $normal_constant_name = qr/^_?[^\W_0-9]\w*\z/; # spent 11µs making 1 call to constant::CORE:qr |
21 | 1 | 13µs | 1 | 6µs | my $tolerable = qr/^[A-Za-z_]\w*\z/; # spent 6µs making 1 call to constant::CORE:qr |
22 | 1 | 13µs | 1 | 7µs | my $boolean = qr/^[01]?\z/; # spent 7µs making 1 call to constant::CORE:qr |
23 | |||||
24 | # spent 72µs (57+15) within constant::BEGIN@24 which was called:
# once (57µs+15µs) by Getopt::Long::BEGIN@219 at line 45 | ||||
25 | # We'd like to do use constant _CAN_PCS => $] > 5.009002 | ||||
26 | # but that's a bit tricky before we load the constant module :-) | ||||
27 | # By doing this, we save several run time checks for *every* call | ||||
28 | # to import. | ||||
29 | 1 | 7µs | my $const = $] > 5.009002; | ||
30 | 1 | 2µs | my $downgrade = $] < 5.015004; # && $] >= 5.008 | ||
31 | 1 | 3µs | my $constarray = exists &_make_const; | ||
32 | 1 | 9µs | if ($const) { | ||
33 | 1 | 24µs | 1 | 12µs | Internals::SvREADONLY($const, 1); # spent 12µs making 1 call to Internals::SvREADONLY |
34 | 1 | 19µs | 1 | 2µs | Internals::SvREADONLY($downgrade, 1); # spent 2µs making 1 call to Internals::SvREADONLY |
35 | 1 | 3µs | $constant::{_CAN_PCS} = \$const; | ||
36 | 1 | 2µs | $constant::{_DOWNGRADE} = \$downgrade; | ||
37 | 1 | 2µs | $constant::{_CAN_PCS_FOR_ARRAY} = \$constarray; | ||
38 | } | ||||
39 | else { | ||||
40 | 2 | 214µs | 2 | 160µs | # spent 92µs (23+69) within constant::BEGIN@40 which was called:
# once (23µs+69µs) by Getopt::Long::BEGIN@219 at line 40 # spent 92µs making 1 call to constant::BEGIN@40
# spent 69µs making 1 call to strict::unimport |
41 | *{"_CAN_PCS"} = sub () {$const}; | ||||
42 | *{"_DOWNGRADE"} = sub () { $downgrade }; | ||||
43 | *{"_CAN_PCS_FOR_ARRAY"} = sub () { $constarray }; | ||||
44 | } | ||||
45 | 1 | 179µs | 1 | 72µs | } # spent 72µs making 1 call to constant::BEGIN@24 |
46 | |||||
47 | #======================================================================= | ||||
48 | # import() - import symbols into user's namespace | ||||
49 | # | ||||
50 | # What we actually do is define a function in the caller's namespace | ||||
51 | # which returns the value. The function we create will normally | ||||
52 | # be inlined as a constant, thereby avoiding further sub calling | ||||
53 | # overhead. | ||||
54 | #======================================================================= | ||||
55 | # spent 28.4ms (23.4+4.94) within constant::import which was called 148 times, avg 192µs/call:
# once (221µs+56µs) by Net::DNS::Resolver::Base::BEGIN@59 at line 59 of Net/DNS/Resolver/Base.pm
# once (231µs+41µs) by Net::DNS::RR::BEGIN@39 at line 39 of Net/DNS/RR.pm
# once (192µs+54µs) by IO::Socket::IP::BEGIN@39 at line 39 of IO/Socket/IP.pm
# once (183µs+59µs) by Getopt::Long::BEGIN@219 at line 219 of Getopt/Long.pm
# once (187µs+48µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@223 at line 223 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (195µs+36µs) by Net::DNS::Question::BEGIN@107 at line 107 of Net/DNS/Question.pm
# once (190µs+40µs) by Encode::Alias::BEGIN@6 at line 6 of Encode/Alias.pm
# once (200µs+26µs) by Net::DNS::Packet::BEGIN@34 at line 34 of Net/DNS/Packet.pm
# once (201µs+26µs) by URI::_punycode::BEGIN@16 at line 16 of URI/_punycode.pm
# once (172µs+53µs) by IO::Socket::IP::BEGIN@36 at line 36 of IO/Socket/IP.pm
# once (177µs+44µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@163 at line 163 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (192µs+29µs) by IO::Socket::SSL::BEGIN@55 at line 55 of IO/Socket/SSL.pm
# once (183µs+37µs) by Mail::SpamAssassin::Constants::BEGIN@403 at line 405 of Mail/SpamAssassin/Constants.pm
# once (171µs+48µs) by Mail::SpamAssassin::HTML::BEGIN@1080 at line 1080 of Mail/SpamAssassin/HTML.pm
# once (181µs+37µs) by Net::DNS::RR::BEGIN@227 at line 227 of Net/DNS/RR.pm
# once (181µs+37µs) by Mail::SpamAssassin::Constants::BEGIN@91 at line 172 of Mail/SpamAssassin/Constants.pm
# once (193µs+25µs) by IO::Socket::SSL::BEGIN@58 at line 58 of IO/Socket/SSL.pm
# once (183µs+34µs) by Net::Cmd::BEGIN@35 at line 35 of Net/Cmd.pm
# once (176µs+41µs) by IO::Socket::SSL::BEGIN@47 at line 47 of IO/Socket/SSL.pm
# once (164µs+51µs) by Net::DNS::Resolver::Base::BEGIN@33 at line 33 of Net/DNS/Resolver/Base.pm
# once (170µs+44µs) by Mail::SpamAssassin::Constants::BEGIN@378 at line 392 of Mail/SpamAssassin/Constants.pm
# once (176µs+38µs) by Mail::SpamAssassin::Plugin::HeaderEval::BEGIN@602 at line 602 of Mail/SpamAssassin/Plugin/HeaderEval.pm
# once (165µs+48µs) by Net::DNS::Resolver::Base::BEGIN@46 at line 46 of Net/DNS/Resolver/Base.pm
# once (194µs+19µs) by IO::Socket::SSL::SSL_Context::BEGIN@2168 at line 2168 of IO/Socket/SSL.pm
# once (165µs+47µs) by Mail::SpamAssassin::Constants::BEGIN@255 at line 260 of Mail/SpamAssassin/Constants.pm
# once (181µs+30µs) by IO::Socket::SSL::BEGIN@308 at line 344 of IO/Socket/SSL.pm
# once (167µs+43µs) by Mail::SpamAssassin::Logger::BEGIN@51 at line 51 of Mail/SpamAssassin/Logger.pm
# once (166µs+42µs) by Net::DNS::Domain::BEGIN@49 at line 51 of Net/DNS/Domain.pm
# once (172µs+35µs) by Mail::SpamAssassin::Plugin::SpamCop::BEGIN@52 at line 52 of Mail/SpamAssassin/Plugin/SpamCop.pm
# once (171µs+36µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@158 at line 158 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (169µs+37µs) by Mail::SpamAssassin::Constants::BEGIN@175 at line 175 of Mail/SpamAssassin/Constants.pm
# once (173µs+33µs) by Mail::SpamAssassin::Plugin::Hashcash::BEGIN@108 at line 108 of Mail/SpamAssassin/Plugin/Hashcash.pm
# once (174µs+30µs) by Net::DNS::Parameters::BEGIN@330 at line 330 of Net/DNS/Parameters.pm
# once (159µs+45µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@157 at line 157 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (152µs+52µs) by Mail::SpamAssassin::Constants::BEGIN@266 at line 348 of Mail/SpamAssassin/Constants.pm
# once (167µs+37µs) by Net::DNS::Resolver::Base::BEGIN@44 at line 44 of Net/DNS/Resolver/Base.pm
# once (170µs+33µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@227 at line 227 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (155µs+48µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@215 at line 215 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (161µs+42µs) by IO::Socket::SSL::SSL_Context::BEGIN@2165 at line 2165 of IO/Socket/SSL.pm
# once (161µs+41µs) by IO::Socket::SSL::PublicSuffix::BEGIN@8 at line 8 of IO/Socket/SSL/PublicSuffix.pm
# once (156µs+46µs) by Time::Local::BEGIN@28 at line 28 of Time/Local.pm
# once (159µs+43µs) by Net::DNS::Domain::BEGIN@54 at line 54 of Net/DNS/Domain.pm
# once (164µs+38µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@178 at line 178 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (166µs+36µs) by Mail::SpamAssassin::Constants::BEGIN@64 at line 64 of Mail/SpamAssassin/Constants.pm
# once (170µs+31µs) by IO::Socket::SSL::BEGIN@46 at line 46 of IO/Socket/SSL.pm
# once (167µs+34µs) by Mail::SpamAssassin::Constants::BEGIN@400 at line 400 of Mail/SpamAssassin/Constants.pm
# once (162µs+39µs) by Getopt::Long::BEGIN@233 at line 233 of Getopt/Long.pm
# once (156µs+45µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@173 at line 173 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (153µs+47µs) by IO::Socket::SSL::BEGIN@291 at line 291 of IO/Socket/SSL.pm
# once (157µs+42µs) by Net::DNS::Domain::BEGIN@53 at line 53 of Net/DNS/Domain.pm
# once (167µs+32µs) by Net::DNS::Resolver::BEGIN@20 at line 20 of Net/DNS/Resolver.pm
# once (162µs+36µs) by Net::Cmd::BEGIN@40 at line 40 of Net/Cmd.pm
# once (158µs+40µs) by File::Spec::Unix::BEGIN@223 at line 223 of File/Spec/Unix.pm
# once (166µs+32µs) by Net::DNS::Resolver::Base::BEGIN@35 at line 35 of Net/DNS/Resolver/Base.pm
# once (164µs+34µs) by Data::Dumper::BEGIN@279 at line 279 of Data/Dumper.pm
# once (156µs+41µs) by Net::DNS::Packet::BEGIN@107 at line 107 of Net/DNS/Packet.pm
# once (153µs+44µs) by Mail::SpamAssassin::BayesStore::DBM::BEGIN@1895 at line 1895 of Mail/SpamAssassin/BayesStore/DBM.pm
# once (162µs+35µs) by Net::DNS::Resolver::Base::BEGIN@45 at line 45 of Net/DNS/Resolver/Base.pm
# once (171µs+26µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@165 at line 165 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (170µs+27µs) by File::Spec::Unix::BEGIN@148 at line 148 of File/Spec/Unix.pm
# once (156µs+40µs) by Mail::SpamAssassin::Constants::BEGIN@368 at line 368 of Mail/SpamAssassin/Constants.pm
# once (160µs+37µs) by Mail::SpamAssassin::ArchiveIterator::BEGIN@34 at line 34 of Mail/SpamAssassin/ArchiveIterator.pm
# once (143µs+53µs) by Getopt::Long::BEGIN@258 at line 263 of Getopt/Long.pm
# once (163µs+33µs) by Net::DNS::Domain::BEGIN@44 at line 47 of Net/DNS/Domain.pm
# once (153µs+43µs) by Net::DNS::Resolver::Base::BEGIN@36 at line 36 of Net/DNS/Resolver/Base.pm
# once (153µs+43µs) by Mail::SpamAssassin::BayesStore::DBM::BEGIN@41 at line 41 of Mail/SpamAssassin/BayesStore/DBM.pm
# once (161µs+35µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@169 at line 169 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (160µs+35µs) by Mail::SpamAssassin::Constants::BEGIN@375 at line 375 of Mail/SpamAssassin/Constants.pm
# once (163µs+32µs) by Mail::SpamAssassin::Plugin::SpamCop::BEGIN@53 at line 53 of Mail/SpamAssassin/Plugin/SpamCop.pm
# once (154µs+41µs) by IO::Socket::SSL::SSL_Context::BEGIN@2169 at line 2169 of IO/Socket/SSL.pm
# once (159µs+35µs) by Mail::SpamAssassin::Constants::BEGIN@356 at line 356 of Mail/SpamAssassin/Constants.pm
# once (165µs+30µs) by Getopt::Long::BEGIN@248 at line 257 of Getopt/Long.pm
# once (162µs+33µs) by Mail::SpamAssassin::Plugin::HeaderEval::BEGIN@604 at line 604 of Mail/SpamAssassin/Plugin/HeaderEval.pm
# once (159µs+35µs) by Mail::SpamAssassin::Locker::UnixNFSSafe::BEGIN@57 at line 57 of Mail/SpamAssassin/Locker/UnixNFSSafe.pm
# once (174µs+20µs) by URI::_punycode::BEGIN@17 at line 17 of URI/_punycode.pm
# once (177µs+16µs) by URI::_punycode::BEGIN@21 at line 21 of URI/_punycode.pm
# once (162µs+32µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@156 at line 156 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (152µs+41µs) by Getopt::Long::BEGIN@237 at line 237 of Getopt/Long.pm
# once (154µs+39µs) by File::Spec::Unix::BEGIN@130 at line 130 of File/Spec/Unix.pm
# once (162µs+30µs) by Getopt::Long::BEGIN@236 at line 236 of Getopt/Long.pm
# once (156µs+36µs) by Net::DNS::Resolver::Base::BEGIN@29 at line 29 of Net/DNS/Resolver/Base.pm
# once (142µs+50µs) by Getopt::Long::BEGIN@239 at line 239 of Getopt/Long.pm
# once (153µs+38µs) by Mail::SpamAssassin::Constants::BEGIN@352 at line 352 of Mail/SpamAssassin/Constants.pm
# once (155µs+35µs) by Mail::SpamAssassin::Constants::BEGIN@370 at line 370 of Mail/SpamAssassin/Constants.pm
# once (156µs+34µs) by Net::DNS::Resolver::BEGIN@18 at line 18 of Net/DNS/Resolver.pm
# once (164µs+26µs) by Mail::SpamAssassin::Plugin::URIDNSBL::BEGIN@307 at line 307 of Mail/SpamAssassin/Plugin/URIDNSBL.pm
# once (164µs+26µs) by URI::_punycode::BEGIN@18 at line 18 of URI/_punycode.pm
# once (157µs+32µs) by Mail::SpamAssassin::Constants::BEGIN@65 at line 65 of Mail/SpamAssassin/Constants.pm
# once (162µs+27µs) by Net::Cmd::BEGIN@39 at line 39 of Net/Cmd.pm
# once (152µs+36µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@219 at line 219 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (152µs+37µs) by Net::DNS::Resolver::Base::BEGIN@31 at line 31 of Net/DNS/Resolver/Base.pm
# once (157µs+31µs) by Mail::SpamAssassin::Constants::BEGIN@62 at line 62 of Mail/SpamAssassin/Constants.pm
# once (161µs+25µs) by IO::Socket::SSL::BEGIN@57 at line 57 of IO/Socket/SSL.pm
# once (156µs+29µs) by IO::Socket::SSL::BEGIN@48 at line 48 of IO/Socket/SSL.pm
# once (140µs+46µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@172 at line 172 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (146µs+39µs) by File::Spec::Unix::BEGIN@245 at line 245 of File/Spec/Unix.pm
# once (140µs+44µs) by Getopt::Long::BEGIN@235 at line 235 of Getopt/Long.pm
# once (169µs+16µs) by URI::_punycode::BEGIN@19 at line 19 of URI/_punycode.pm
# once (158µs+26µs) by IO::Socket::SSL::BEGIN@52 at line 52 of IO/Socket/SSL.pm
# once (166µs+19µs) by IO::Socket::SSL::BEGIN@49 at line 49 of IO/Socket/SSL.pm
# once (140µs+44µs) by Getopt::Long::BEGIN@247 at line 247 of Getopt/Long.pm
# once (158µs+25µs) by Mail::SpamAssassin::Plugin::HeaderEval::BEGIN@603 at line 603 of Mail/SpamAssassin/Plugin/HeaderEval.pm
# once (153µs+31µs) by Net::DNS::Resolver::Base::BEGIN@40 at line 40 of Net/DNS/Resolver/Base.pm
# once (153µs+30µs) by Mail::SpamAssassin::Util::BEGIN@84 at line 84 of Mail/SpamAssassin/Util.pm
# once (160µs+23µs) by IO::Socket::SSL::BEGIN@293 at line 293 of IO/Socket/SSL.pm
# once (152µs+30µs) by Time::Local::BEGIN@29 at line 29 of Time/Local.pm
# once (149µs+32µs) by Mail::SpamAssassin::Util::Progress::BEGIN@52 at line 52 of Mail/SpamAssassin/Util/Progress.pm
# once (154µs+26µs) by Net::DNS::Domain::BEGIN@56 at line 56 of Net/DNS/Domain.pm
# once (149µs+30µs) by Mail::SpamAssassin::Bayes::Combine::BEGIN@37 at line 37 of Mail/SpamAssassin/Bayes/CombineChi.pm
# once (150µs+29µs) by Mail::SpamAssassin::Constants::BEGIN@366 at line 366 of Mail/SpamAssassin/Constants.pm
# once (151µs+27µs) by Net::Cmd::BEGIN@37 at line 37 of Net/Cmd.pm
# once (162µs+16µs) by URI::_punycode::BEGIN@20 at line 20 of URI/_punycode.pm
# once (152µs+26µs) by Net::Cmd::BEGIN@42 at line 42 of Net/Cmd.pm
# once (141µs+36µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@174 at line 174 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (150µs+27µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@159 at line 159 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (144µs+33µs) by Mail::SpamAssassin::Constants::BEGIN@63 at line 63 of Mail/SpamAssassin/Constants.pm
# once (130µs+46µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@175 at line 175 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (151µs+26µs) by Getopt::Long::BEGIN@234 at line 234 of Getopt/Long.pm
# once (149µs+27µs) by Net::DNS::RR::OPT::BEGIN@25 at line 25 of Net/DNS/RR/OPT.pm
# once (149µs+27µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@168 at line 168 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (148µs+27µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@164 at line 164 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (146µs+30µs) by Getopt::Long::BEGIN@231 at line 231 of Getopt/Long.pm
# once (159µs+16µs) by Net::Cmd::BEGIN@38 at line 38 of Net/Cmd.pm
# once (155µs+19µs) by IO::Socket::SSL::SSL_Context::BEGIN@2166 at line 2166 of IO/Socket/SSL.pm
# once (154µs+20µs) by IO::Socket::SSL::BEGIN@53 at line 53 of IO/Socket/SSL.pm
# once (144µs+31µs) by Encode::BEGIN@8 at line 8 of Encode.pm
# once (156µs+17µs) by IO::Socket::SSL::BEGIN@56 at line 56 of IO/Socket/SSL.pm
# once (155µs+17µs) by File::Spec::Unix::BEGIN@139 at line 139 of File/Spec/Unix.pm
# once (148µs+24µs) by Mail::SpamAssassin::Util::BEGIN@85 at line 85 of Mail/SpamAssassin/Util.pm
# once (141µs+30µs) by Time::Local::BEGIN@27 at line 27 of Time/Local.pm
# once (134µs+35µs) by Net::Cmd::BEGIN@36 at line 36 of Net/Cmd.pm
# once (152µs+17µs) by Net::DNS::RR::OPT::BEGIN@27 at line 27 of Net/DNS/RR/OPT.pm
# once (148µs+21µs) by URI::_punycode::BEGIN@22 at line 22 of URI/_punycode.pm
# once (131µs+37µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@179 at line 179 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (146µs+18µs) by Mail::SpamAssassin::Constants::BEGIN@180 at line 250 of Mail/SpamAssassin/Constants.pm
# once (140µs+23µs) by Mail::SpamAssassin::Constants::BEGIN@372 at line 372 of Mail/SpamAssassin/Constants.pm
# once (135µs+27µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@167 at line 167 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (135µs+27µs) by Mail::SpamAssassin::Plugin::Bayes::BEGIN@166 at line 166 of Mail/SpamAssassin/Plugin/Bayes.pm
# once (144µs+17µs) by IO::Socket::SSL::BEGIN@59 at line 59 of IO/Socket/SSL.pm
# once (126µs+27µs) by Getopt::Long::BEGIN@229 at line 229 of Getopt/Long.pm
# once (114µs+34µs) by Getopt::Long::BEGIN@240 at line 240 of Getopt/Long.pm
# once (116µs+18µs) by Mail::SpamAssassin::BayesStore::DBM::BEGIN@1897 at line 1897 of Mail/SpamAssassin/BayesStore/DBM.pm
# once (112µs+19µs) by Mail::SpamAssassin::Logger::BEGIN@52 at line 52 of Mail/SpamAssassin/Logger.pm
# once (108µs+17µs) by Mail::SpamAssassin::BayesStore::DBM::BEGIN@1896 at line 1896 of Mail/SpamAssassin/BayesStore/DBM.pm
# once (106µs+19µs) by Mail::SpamAssassin::Logger::BEGIN@53 at line 53 of Mail/SpamAssassin/Logger.pm
# once (108µs+17µs) by Mail::SpamAssassin::BayesStore::DBM::BEGIN@1899 at line 1899 of Mail/SpamAssassin/BayesStore/DBM.pm
# once (105µs+17µs) by Mail::SpamAssassin::BayesStore::DBM::BEGIN@1900 at line 1900 of Mail/SpamAssassin/BayesStore/DBM.pm
# once (105µs+16µs) by Mail::SpamAssassin::Logger::BEGIN@54 at line 54 of Mail/SpamAssassin/Logger.pm | ||||
56 | 148 | 326µs | my $class = shift; | ||
57 | 148 | 276µs | return unless @_; # Ignore 'use constant;' | ||
58 | 148 | 270µs | my $constants; | ||
59 | 148 | 405µs | my $multiple = ref $_[0]; | ||
60 | 148 | 344µs | my $caller = caller; | ||
61 | 148 | 272µs | my $flush_mro; | ||
62 | my $symtab; | ||||
63 | |||||
64 | 148 | 550µs | if (_CAN_PCS) { | ||
65 | 2 | 332µs | 2 | 120µs | # spent 73µs (26+47) within constant::BEGIN@65 which was called:
# once (26µs+47µs) by Getopt::Long::BEGIN@219 at line 65 # spent 73µs making 1 call to constant::BEGIN@65
# spent 47µs making 1 call to strict::unimport |
66 | 296 | 1.18ms | $symtab = \%{$caller . '::'}; | ||
67 | }; | ||||
68 | |||||
69 | 148 | 525µs | if ( $multiple ) { | ||
70 | if (ref $_[0] ne 'HASH') { | ||||
71 | require Carp; | ||||
72 | Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'"); | ||||
73 | } | ||||
74 | $constants = shift; | ||||
75 | } else { | ||||
76 | 148 | 281µs | unless (defined $_[0]) { | ||
77 | require Carp; | ||||
78 | Carp::croak("Can't use undef as constant name"); | ||||
79 | } | ||||
80 | 148 | 1.39ms | $constants->{+shift} = undef; | ||
81 | } | ||||
82 | |||||
83 | 148 | 925µs | foreach my $name ( keys %$constants ) { | ||
84 | 148 | 247µs | my $pkg; | ||
85 | 148 | 268µs | my $symtab = $symtab; | ||
86 | 148 | 288µs | my $orig_name = $name; | ||
87 | 148 | 2.92ms | 148 | 1.43ms | if ($name =~ s/(.*)(?:::|')(?=.)//s) { # spent 1.43ms making 148 calls to constant::CORE:subst, avg 10µs/call |
88 | $pkg = $1; | ||||
89 | if (_CAN_PCS && $pkg ne $caller) { | ||||
90 | 2 | 482µs | 2 | 125µs | # spent 72µs (20+53) within constant::BEGIN@90 which was called:
# once (20µs+53µs) by Getopt::Long::BEGIN@219 at line 90 # spent 72µs making 1 call to constant::BEGIN@90
# spent 53µs making 1 call to strict::unimport |
91 | $symtab = \%{$pkg . '::'}; | ||||
92 | } | ||||
93 | } | ||||
94 | else { | ||||
95 | 148 | 297µs | $pkg = $caller; | ||
96 | } | ||||
97 | |||||
98 | # Normal constant name | ||||
99 | 148 | 4.45ms | 296 | 1.97ms | if ($name =~ $normal_constant_name and !$forbidden{$name}) { # spent 1.02ms making 148 calls to constant::CORE:match, avg 7µs/call
# spent 945µs making 148 calls to constant::CORE:regcomp, avg 6µs/call |
100 | # Everything is okay | ||||
101 | |||||
102 | # Name forced into main, but we're not in main. Fatal. | ||||
103 | } elsif ($forced_into_main{$name} and $pkg ne 'main') { | ||||
104 | require Carp; | ||||
105 | Carp::croak("Constant name '$name' is forced into main::"); | ||||
106 | |||||
107 | # Starts with double underscore. Fatal. | ||||
108 | } elsif ($name =~ /^__/) { | ||||
109 | require Carp; | ||||
110 | Carp::croak("Constant name '$name' begins with '__'"); | ||||
111 | |||||
112 | # Maybe the name is tolerable | ||||
113 | } elsif ($name =~ $tolerable) { | ||||
114 | # Then we'll warn only if you've asked for warnings | ||||
115 | if (warnings::enabled()) { | ||||
116 | if ($keywords{$name}) { | ||||
117 | warnings::warn("Constant name '$name' is a Perl keyword"); | ||||
118 | } elsif ($forced_into_main{$name}) { | ||||
119 | warnings::warn("Constant name '$name' is " . | ||||
120 | "forced into package main::"); | ||||
121 | } | ||||
122 | } | ||||
123 | |||||
124 | # Looks like a boolean | ||||
125 | # use constant FRED == fred; | ||||
126 | } elsif ($name =~ $boolean) { | ||||
127 | require Carp; | ||||
128 | if (@_) { | ||||
129 | Carp::croak("Constant name '$name' is invalid"); | ||||
130 | } else { | ||||
131 | Carp::croak("Constant name looks like boolean value"); | ||||
132 | } | ||||
133 | |||||
134 | } else { | ||||
135 | # Must have bad characters | ||||
136 | require Carp; | ||||
137 | Carp::croak("Constant name '$name' has invalid characters"); | ||||
138 | } | ||||
139 | |||||
140 | { | ||||
141 | 150 | 1.78ms | 2 | 106µs | # spent 65µs (23+41) within constant::BEGIN@141 which was called:
# once (23µs+41µs) by Getopt::Long::BEGIN@219 at line 141 # spent 65µs making 1 call to constant::BEGIN@141
# spent 41µs making 1 call to strict::unimport |
142 | 148 | 450µs | my $full_name = "${pkg}::$name"; | ||
143 | 148 | 1.21ms | $declared{$full_name}++; | ||
144 | 148 | 582µs | if ($multiple || @_ == 1) { | ||
145 | 146 | 361µs | my $scalar = $multiple ? $constants->{$orig_name} : $_[0]; | ||
146 | |||||
147 | if (_DOWNGRADE) { # for 5.8 to 5.14 | ||||
148 | # Work around perl bug #31991: Sub names (actually glob | ||||
149 | # names in general) ignore the UTF8 flag. So we have to | ||||
150 | # turn it off to get the "right" symbol table entry. | ||||
151 | utf8::is_utf8 $name and utf8::encode $name; | ||||
152 | } | ||||
153 | |||||
154 | # The constant serves to optimise this entire block out on | ||||
155 | # 5.8 and earlier. | ||||
156 | 146 | 669µs | if (_CAN_PCS) { | ||
157 | # Use a reference as a proxy for a constant subroutine. | ||||
158 | # If this is not a glob yet, it saves space. If it is | ||||
159 | # a glob, we must still create it this way to get the | ||||
160 | # right internal flags set, as constants are distinct | ||||
161 | # from subroutines created with sub(){...}. | ||||
162 | # The check in Perl_ck_rvconst knows that inlinable | ||||
163 | # constants from cv_const_sv are read only. So we have to: | ||||
164 | 146 | 2.16ms | 146 | 955µs | Internals::SvREADONLY($scalar, 1); # spent 955µs making 146 calls to Internals::SvREADONLY, avg 7µs/call |
165 | 146 | 666µs | if (!exists $symtab->{$name}) { | ||
166 | 146 | 399µs | $symtab->{$name} = \$scalar; | ||
167 | 146 | 1.02ms | ++$flush_mro->{$pkg}; | ||
168 | } | ||||
169 | else { | ||||
170 | local $constant::{_dummy} = \$scalar; | ||||
171 | *$full_name = \&{"_dummy"}; | ||||
172 | } | ||||
173 | } else { | ||||
174 | *$full_name = sub () { $scalar }; | ||||
175 | } | ||||
176 | } elsif (@_) { | ||||
177 | 1 | 5µs | my @list = @_; | ||
178 | 1 | 4µs | if (_CAN_PCS_FOR_ARRAY) { | ||
179 | 1 | 88µs | 4 | 13µs | _make_const($list[$_]) for 0..$#list; # spent 13µs making 4 calls to constant::_make_const, avg 3µs/call |
180 | 1 | 10µs | 1 | 2µs | _make_const(@list); # spent 2µs making 1 call to constant::_make_const |
181 | 1 | 4µs | if (!exists $symtab->{$name}) { | ||
182 | 1 | 3µs | $symtab->{$name} = \@list; | ||
183 | 1 | 3µs | $flush_mro->{$pkg}++; | ||
184 | } | ||||
185 | else { | ||||
186 | local $constant::{_dummy} = \@list; | ||||
187 | *$full_name = \&{"_dummy"}; | ||||
188 | } | ||||
189 | } | ||||
190 | else { *$full_name = sub () { @list }; } | ||||
191 | } else { | ||||
192 | 9 | 8.24ms | # spent 61µs within constant::__ANON__[/usr/local/lib/perl5/5.24/constant.pm:192] which was called 8 times, avg 8µs/call:
# 5 times (43µs+0s) by Mail::SpamAssassin::Util::am_running_on_windows at line 220 of Mail/SpamAssassin/Util.pm, avg 9µs/call
# once (8µs+0s) by Mail::SpamAssassin::Util::BEGIN@88 at line 89 of Mail/SpamAssassin/Util.pm
# once (6µs+0s) by Mail::SpamAssassin::Util::clean_path_in_taint_mode at line 140 of Mail/SpamAssassin/Util.pm
# once (4µs+0s) by Mail::SpamAssassin::Util::portable_getpwuid at line 767 of Mail/SpamAssassin/Util.pm | ||
193 | } | ||||
194 | } | ||||
195 | } | ||||
196 | # Flush the cache exactly once if we make any direct symbol table changes. | ||||
197 | 148 | 2.78ms | if (_CAN_PCS && $flush_mro) { | ||
198 | 147 | 2.74ms | 147 | 569µs | mro::method_changed_in($_) for keys %$flush_mro; # spent 569µs making 147 calls to mro::method_changed_in, avg 4µs/call |
199 | } | ||||
200 | } | ||||
201 | |||||
202 | 1 | 20µs | 1; | ||
203 | |||||
204 | __END__ | ||||
# spent 1.02ms within constant::CORE:match which was called 148 times, avg 7µs/call:
# 148 times (1.02ms+0s) by constant::import at line 99, avg 7µs/call | |||||
sub constant::CORE:qr; # opcode | |||||
# spent 945µs within constant::CORE:regcomp which was called 148 times, avg 6µs/call:
# 148 times (945µs+0s) by constant::import at line 99, avg 6µs/call | |||||
# spent 1.43ms within constant::CORE:subst which was called 148 times, avg 10µs/call:
# 148 times (1.43ms+0s) by constant::import at line 87, avg 10µs/call | |||||
sub constant::_make_const; # xsub |