Filename | /usr/share/perl/5.20/constant.pm |
Statements | Executed 5146 statements in 7.13ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
203 | 203 | 38 | 4.05ms | 5.23ms | import | constant::
225 | 1 | 1 | 506µs | 506µs | CORE:match (opcode) | constant::
225 | 1 | 1 | 304µs | 304µs | CORE:regcomp (opcode) | constant::
1 | 1 | 1 | 21µs | 21µs | BEGIN@2 | constant::
1 | 1 | 1 | 16µs | 18µs | BEGIN@24 | constant::
1 | 1 | 1 | 14µs | 26µs | BEGIN@39 | constant::
1 | 1 | 1 | 8µs | 17µs | BEGIN@126 | constant::
1 | 1 | 1 | 7µs | 22µs | BEGIN@3 | constant::
1 | 1 | 1 | 7µs | 90µs | BEGIN@4 | constant::
1 | 1 | 1 | 7µs | 17µs | BEGIN@64 | constant::
1 | 1 | 1 | 7µs | 40µs | BEGIN@6 | constant::
3 | 3 | 1 | 5µs | 5µs | CORE:qr (opcode) | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:159] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:175] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:177] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:40] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:41] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:42] | constant::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package constant; | ||||
2 | 2 | 55µs | 1 | 21µs | # spent 21µs within constant::BEGIN@2 which was called:
# once (21µs+0s) by C4::Boolean::BEGIN@55 at line 2 # spent 21µs making 1 call to constant::BEGIN@2 |
3 | 2 | 25µs | 2 | 36µs | # spent 22µs (7+14) within constant::BEGIN@3 which was called:
# once (7µs+14µs) by C4::Boolean::BEGIN@55 at line 3 # spent 22µs making 1 call to constant::BEGIN@3
# spent 14µs making 1 call to strict::import |
4 | 2 | 32µs | 2 | 172µs | # spent 90µs (7+83) within constant::BEGIN@4 which was called:
# once (7µs+83µs) by C4::Boolean::BEGIN@55 at line 4 # spent 90µs making 1 call to constant::BEGIN@4
# spent 83µs making 1 call to warnings::register::import |
5 | |||||
6 | 2 | 495µs | 2 | 74µs | # spent 40µs (7+34) within constant::BEGIN@6 which was called:
# once (7µs+34µs) by C4::Boolean::BEGIN@55 at line 6 # spent 40µs making 1 call to constant::BEGIN@6
# spent 34µs making 1 call to vars::import |
7 | 1 | 500ns | $VERSION = '1.31'; | ||
8 | |||||
9 | #======================================================================= | ||||
10 | |||||
11 | # Some names are evil choices. | ||||
12 | 1 | 6µs | my %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD }; | ||
13 | 1 | 1µs | $keywords{UNITCHECK}++ if $] > 5.009; | ||
14 | |||||
15 | 1 | 6µs | my %forced_into_main = map +($_, 1), | ||
16 | qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG }; | ||||
17 | |||||
18 | 1 | 6µs | my %forbidden = (%keywords, %forced_into_main); | ||
19 | |||||
20 | 1 | 10µs | 1 | 4µs | my $normal_constant_name = qr/^_?[^\W_0-9]\w*\z/; # spent 4µs making 1 call to constant::CORE:qr |
21 | 1 | 3µs | 1 | 900ns | my $tolerable = qr/^[A-Za-z_]\w*\z/; # spent 900ns making 1 call to constant::CORE:qr |
22 | 1 | 2µs | 1 | 600ns | my $boolean = qr/^[01]?\z/; # spent 600ns making 1 call to constant::CORE:qr |
23 | |||||
24 | # spent 18µs (16+2) within constant::BEGIN@24 which was called:
# once (16µs+2µs) by C4::Boolean::BEGIN@55 at line 44 | ||||
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 1 run time check for *every* call to import. | ||||
28 | 1 | 1µs | my $const = $] > 5.009002; | ||
29 | 1 | 500ns | my $downgrade = $] < 5.015004; # && $] >= 5.008 | ||
30 | 1 | 400ns | my $constarray = exists &_make_const; | ||
31 | 1 | 3µs | if ($const) { | ||
32 | 1 | 8µs | 1 | 1µs | Internals::SvREADONLY($const, 1); # spent 1µs making 1 call to Internals::SvREADONLY |
33 | 1 | 2µs | 1 | 500ns | Internals::SvREADONLY($downgrade, 1); # spent 500ns making 1 call to Internals::SvREADONLY |
34 | 1 | 1µs | $constant::{_CAN_PCS} = \$const; | ||
35 | 1 | 300ns | $constant::{_DOWNGRADE} = \$downgrade; | ||
36 | 1 | 600ns | $constant::{_CAN_PCS_FOR_ARRAY} = \$constarray; | ||
37 | } | ||||
38 | else { | ||||
39 | 2 | 96µs | 2 | 39µs | # spent 26µs (14+13) within constant::BEGIN@39 which was called:
# once (14µs+13µs) by C4::Boolean::BEGIN@55 at line 39 # spent 26µs making 1 call to constant::BEGIN@39
# spent 13µs making 1 call to strict::unimport |
40 | *{"_CAN_PCS"} = sub () {$const}; | ||||
41 | *{"_DOWNGRADE"} = sub () { $downgrade }; | ||||
42 | *{"_CAN_PCS_FOR_ARRAY"} = sub () { $constarray }; | ||||
43 | } | ||||
44 | 1 | 79µs | 1 | 18µs | } # spent 18µs making 1 call to constant::BEGIN@24 |
45 | |||||
46 | #======================================================================= | ||||
47 | # import() - import symbols into user's namespace | ||||
48 | # | ||||
49 | # What we actually do is define a function in the caller's namespace | ||||
50 | # which returns the value. The function we create will normally | ||||
51 | # be inlined as a constant, thereby avoiding further sub calling | ||||
52 | # overhead. | ||||
53 | #======================================================================= | ||||
54 | # spent 5.23ms (4.05+1.18) within constant::import which was called 203 times, avg 26µs/call:
# once (153µs+47µs) by XML::LibXML::BEGIN@237 at line 238 of XML/LibXML.pm
# once (183µs+9µs) by XML::NamespaceSupport::BEGIN@9 at line 9 of XML/NamespaceSupport.pm
# once (78µs+12µs) by MultipartBuffer::BEGIN@3979 at line 3979 of CGI.pm
# once (60µs+8µs) by File::Temp::BEGIN@95 at line 95 of File/Temp.pm
# once (47µs+16µs) by CGI::Util::BEGIN@11 at line 11 of CGI/Util.pm
# once (31µs+30µs) by DateTime::TimeZone::BEGIN@23 at line 23 of DateTime/TimeZone.pm
# once (22µs+34µs) by XML::LibXML::BEGIN@180 at line 180 of XML/LibXML.pm
# once (46µs+4µs) by XML::LibXML::BEGIN@175 at line 175 of XML/LibXML.pm
# once (37µs+10µs) by CGI::BEGIN@14 at line 14 of CGI.pm
# once (34µs+10µs) by Template::Provider::BEGIN@50 at line 50 of Template/Provider.pm
# once (33µs+11µs) by Math::BigInt::Calc::BEGIN@1909 at line 1909 of Math/BigInt/Calc.pm
# once (31µs+12µs) by C4::Boolean::BEGIN@55 at line 55 of C4/Boolean.pm
# once (31µs+11µs) by YAML::BEGIN@14 at line 14 of YAML.pm
# once (32µs+9µs) by YAML::Syck::BEGIN@38 at line 55 of YAML/Syck.pm
# once (31µs+10µs) by File::Temp::BEGIN@83 at line 83 of File/Temp.pm
# once (31µs+9µs) by JSON::Backend::XS::BEGIN@9 at line 9 of (eval 68)[JSON.pm:268]
# once (29µs+11µs) by DateTime::Duration::BEGIN@20 at line 20 of DateTime/Duration.pm
# once (28µs+11µs) by Set::Infinite::_recurrence::BEGIN@9 at line 9 of Set/Infinite/_recurrence.pm
# once (29µs+10µs) by DateTime::TimeZone::BEGIN@17 at line 17 of DateTime/TimeZone.pm
# once (30µs+9µs) by Module::Load::Conditional::BEGIN@16 at line 16 of Module/Load/Conditional.pm
# once (29µs+9µs) by Encode::BEGIN@8 at line 8 of Encode.pm
# once (28µs+8µs) by Template::Constants::BEGIN@40 at line 40 of Template/Constants.pm
# once (27µs+10µs) by DateTime::BEGIN@72 at line 72 of DateTime.pm
# once (28µs+9µs) by MARC::Charset::Constants::BEGIN@22 at line 22 of MARC/Charset/Constants.pm
# once (30µs+4µs) by Template::Constants::BEGIN@53 at line 53 of Template/Constants.pm
# once (30µs+5µs) by MARC::Charset::Constants::BEGIN@30 at line 30 of MARC/Charset/Constants.pm
# once (26µs+8µs) by MARC::Field::BEGIN@8 at line 8 of MARC/Field.pm
# once (14µs+20µs) by XML::LibXML::BEGIN@169 at line 169 of XML/LibXML.pm
# once (27µs+8µs) by Template::Provider::BEGIN@51 at line 51 of Template/Provider.pm
# once (26µs+8µs) by Try::Tiny::ScopeGuard::BEGIN@144 at line 144 of Try/Tiny.pm
# once (27µs+7µs) by DateTime::SpanSet::BEGIN@16 at line 16 of DateTime/SpanSet.pm
# once (27µs+7µs) by Template::Provider::BEGIN@53 at line 53 of Template/Provider.pm
# once (26µs+7µs) by Time::Local::BEGIN@27 at line 27 of Time/Local.pm
# once (26µs+8µs) by namespace::clean::BEGIN@146 at line 146 of namespace/clean.pm
# once (26µs+7µs) by Template::Provider::BEGIN@52 at line 52 of Template/Provider.pm
# once (25µs+7µs) by Template::Provider::BEGIN@55 at line 55 of Template/Provider.pm
# once (25µs+7µs) by Template::Provider::BEGIN@54 at line 54 of Template/Provider.pm
# once (15µs+17µs) by XML::LibXML::BEGIN@167 at line 167 of XML/LibXML.pm
# once (22µs+8µs) by Template::Exception::BEGIN@24 at line 24 of Template/Exception.pm
# once (22µs+7µs) by MARC::File::USMARC::BEGIN@21 at line 21 of MARC/File/USMARC.pm
# once (24µs+6µs) by File::Spec::Unix::BEGIN@130 at line 130 of File/Spec/Unix.pm
# once (22µs+7µs) by File::Spec::Unix::BEGIN@69 at line 69 of File/Spec/Unix.pm
# once (22µs+6µs) by Set::Infinite::Basic::BEGIN@20 at line 20 of Set/Infinite/Basic.pm
# once (21µs+7µs) by Encode::Alias::BEGIN@6 at line 6 of Encode/Alias.pm
# once (21µs+6µs) by C4::VirtualShelves::BEGIN@27 at line 27 of C4/VirtualShelves.pm
# once (20µs+7µs) by XML::LibXML::BEGIN@162 at line 162 of XML/LibXML.pm
# once (19µs+7µs) by DateTime::TimeZone::BEGIN@18 at line 18 of DateTime/TimeZone.pm
# once (21µs+5µs) by JSON::Backend::XS::BEGIN@11 at line 11 of (eval 68)[JSON.pm:268]
# once (21µs+5µs) by File::Spec::Unix::BEGIN@72 at line 72 of File/Spec/Unix.pm
# once (20µs+6µs) by XML::SAX::BEGIN@20 at line 20 of XML/SAX.pm
# once (21µs+4µs) by XML::LibXML::Error::BEGIN@47 at line 47 of XML/LibXML/Error.pm
# once (20µs+6µs) by MARC::Charset::Constants::BEGIN@31 at line 31 of MARC/Charset/Constants.pm
# once (21µs+4µs) by DateTime::BEGIN@74 at line 74 of DateTime.pm
# once (19µs+6µs) by DateTime::Set::BEGIN@14 at line 14 of DateTime/Set.pm
# once (19µs+6µs) by Data::Dumper::BEGIN@272 at line 272 of Data/Dumper.pm
# once (18µs+6µs) by MARC::Record::BEGIN@35 at line 35 of MARC/Record.pm
# once (18µs+6µs) by DateTime::Span::BEGIN@15 at line 15 of DateTime/Span.pm
# once (18µs+5µs) by File::Spec::Unix::BEGIN@138 at line 138 of File/Spec/Unix.pm
# once (18µs+6µs) by C4::Context::BEGIN@191 at line 191 of C4/Context.pm
# once (18µs+6µs) by XML::LibXML::BEGIN@23 at line 23 of XML/LibXML.pm
# once (18µs+6µs) by XML::LibXML::Error::BEGIN@34 at line 34 of XML/LibXML/Error.pm
# once (17µs+6µs) by DateTime::TimeZone::BEGIN@22 at line 22 of DateTime/TimeZone.pm
# once (17µs+6µs) by XML::NamespaceSupport::BEGIN@10 at line 10 of XML/NamespaceSupport.pm
# once (18µs+5µs) by namespace::clean::BEGIN@147 at line 147 of namespace/clean.pm
# once (16µs+6µs) by DateTime::TimeZone::BEGIN@24 at line 24 of DateTime/TimeZone.pm
# once (17µs+6µs) by Template::Service::BEGIN@31 at line 31 of Template/Service.pm
# once (17µs+6µs) by DateTime::TimeZone::BEGIN@21 at line 21 of DateTime/TimeZone.pm
# once (18µs+4µs) by MARC::Charset::Constants::BEGIN@39 at line 39 of MARC/Charset/Constants.pm
# once (17µs+5µs) by Module::Load::Conditional::BEGIN@17 at line 17 of Module/Load/Conditional.pm
# once (17µs+5µs) by Set::Infinite::_recurrence::BEGIN@10 at line 10 of Set/Infinite/_recurrence.pm
# once (17µs+5µs) by MARC::Charset::Constants::BEGIN@24 at line 24 of MARC/Charset/Constants.pm
# once (17µs+5µs) by JSON::Backend::XS::BEGIN@18 at line 18 of (eval 68)[JSON.pm:268]
# once (17µs+5µs) by File::Spec::Unix::BEGIN@75 at line 75 of File/Spec/Unix.pm
# once (17µs+5µs) by Template::Constants::BEGIN@41 at line 41 of Template/Constants.pm
# once (18µs+4µs) by MARC::Charset::Constants::BEGIN@46 at line 46 of MARC/Charset/Constants.pm
# once (16µs+6µs) by DateTime::TimeZone::BEGIN@25 at line 25 of DateTime/TimeZone.pm
# once (18µs+4µs) by XML::LibXML::Error::BEGIN@49 at line 49 of XML/LibXML/Error.pm
# once (16µs+5µs) by MARC::Charset::Constants::BEGIN@42 at line 42 of MARC/Charset/Constants.pm
# once (17µs+5µs) by File::Temp::BEGIN@86 at line 86 of File/Temp.pm
# once (17µs+4µs) by XML::LibXML::Error::BEGIN@45 at line 45 of XML/LibXML/Error.pm
# once (17µs+5µs) by Module::Load::Conditional::BEGIN@18 at line 18 of Module/Load/Conditional.pm
# once (17µs+5µs) by Template::Exception::BEGIN@25 at line 25 of Template/Exception.pm
# once (17µs+4µs) by XML::LibXML::Error::BEGIN@58 at line 58 of XML/LibXML/Error.pm
# once (17µs+4µs) by Time::Local::BEGIN@28 at line 28 of Time/Local.pm
# once (16µs+5µs) by DateTime::Span::BEGIN@16 at line 16 of DateTime/Span.pm
# once (16µs+5µs) by DateTime::SpanSet::BEGIN@17 at line 17 of DateTime/SpanSet.pm
# once (16µs+5µs) by MARC::File::USMARC::BEGIN@22 at line 22 of MARC/File/USMARC.pm
# once (14µs+7µs) by Template::Constants::BEGIN@71 at line 71 of Template/Constants.pm
# once (17µs+4µs) by File::Temp::BEGIN@90 at line 90 of File/Temp.pm
# once (17µs+4µs) by XML::LibXML::Error::BEGIN@59 at line 59 of XML/LibXML/Error.pm
# once (15µs+6µs) by DateTime::TimeZone::BEGIN@27 at line 27 of DateTime/TimeZone.pm
# once (16µs+5µs) by XML::LibXML::BEGIN@176 at line 176 of XML/LibXML.pm
# once (16µs+4µs) by XML::LibXML::BEGIN@24 at line 24 of XML/LibXML.pm
# once (16µs+5µs) by File::Temp::BEGIN@96 at line 96 of File/Temp.pm
# once (16µs+5µs) by XML::LibXML::BEGIN@181 at line 181 of XML/LibXML.pm
# once (16µs+5µs) by DateTime::Set::BEGIN@15 at line 15 of DateTime/Set.pm
# once (16µs+5µs) by MARC::Field::BEGIN@9 at line 9 of MARC/Field.pm
# once (16µs+5µs) by C4::VirtualShelves::BEGIN@28 at line 28 of C4/VirtualShelves.pm
# once (16µs+4µs) by Set::Infinite::Basic::BEGIN@21 at line 21 of Set/Infinite/Basic.pm
# once (16µs+5µs) by MARC::File::USMARC::BEGIN@23 at line 23 of MARC/File/USMARC.pm
# once (16µs+4µs) by DateTime::BEGIN@75 at line 75 of DateTime.pm
# once (15µs+5µs) by DateTime::TimeZone::BEGIN@26 at line 26 of DateTime/TimeZone.pm
# once (16µs+4µs) by XML::NamespaceSupport::BEGIN@15 at line 15 of XML/NamespaceSupport.pm
# once (16µs+4µs) by MARC::Charset::Constants::BEGIN@25 at line 25 of MARC/Charset/Constants.pm
# once (16µs+4µs) by MARC::Charset::Constants::BEGIN@27 at line 27 of MARC/Charset/Constants.pm
# once (16µs+4µs) by MARC::Charset::Constants::BEGIN@29 at line 29 of MARC/Charset/Constants.pm
# once (15µs+5µs) by XML::SAX::BEGIN@22 at line 22 of XML/SAX.pm
# once (16µs+4µs) by DateTime::BEGIN@78 at line 78 of DateTime.pm
# once (15µs+4µs) by MARC::File::USMARC::BEGIN@24 at line 24 of MARC/File/USMARC.pm
# once (15µs+4µs) by XML::LibXML::BEGIN@163 at line 163 of XML/LibXML.pm
# once (15µs+4µs) by XML::LibXML::Error::BEGIN@35 at line 35 of XML/LibXML/Error.pm
# once (16µs+4µs) by File::Temp::BEGIN@94 at line 94 of File/Temp.pm
# once (16µs+4µs) by Template::Constants::BEGIN@67 at line 67 of Template/Constants.pm
# once (16µs+3µs) by DateTime::BEGIN@76 at line 76 of DateTime.pm
# once (15µs+4µs) by XML::LibXML::Error::BEGIN@37 at line 37 of XML/LibXML/Error.pm
# once (15µs+4µs) by Template::Constants::BEGIN@48 at line 48 of Template/Constants.pm
# once (15µs+5µs) by XML::NamespaceSupport::BEGIN@11 at line 11 of XML/NamespaceSupport.pm
# once (15µs+4µs) by XML::LibXML::Error::BEGIN@41 at line 41 of XML/LibXML/Error.pm
# once (15µs+4µs) by Template::Constants::BEGIN@43 at line 43 of Template/Constants.pm
# once (15µs+4µs) by Template::Constants::BEGIN@45 at line 45 of Template/Constants.pm
# once (15µs+4µs) by XML::LibXML::BEGIN@164 at line 164 of XML/LibXML.pm
# once (15µs+4µs) by XML::LibXML::Error::BEGIN@52 at line 52 of XML/LibXML/Error.pm
# once (15µs+4µs) by MARC::Charset::Constants::BEGIN@26 at line 26 of MARC/Charset/Constants.pm
# once (15µs+4µs) by Template::Constants::BEGIN@75 at line 75 of Template/Constants.pm
# once (15µs+4µs) by C4::VirtualShelves::BEGIN@29 at line 29 of C4/VirtualShelves.pm
# once (15µs+4µs) by MARC::Charset::Constants::BEGIN@34 at line 34 of MARC/Charset/Constants.pm
# once (15µs+4µs) by XML::NamespaceSupport::BEGIN@14 at line 14 of XML/NamespaceSupport.pm
# once (15µs+4µs) by XML::NamespaceSupport::BEGIN@12 at line 12 of XML/NamespaceSupport.pm
# once (15µs+4µs) by XML::LibXML::Error::BEGIN@63 at line 63 of XML/LibXML/Error.pm
# once (15µs+4µs) by MARC::Charset::Constants::BEGIN@40 at line 40 of MARC/Charset/Constants.pm
# once (15µs+4µs) by MARC::Charset::Constants::BEGIN@37 at line 37 of MARC/Charset/Constants.pm
# once (15µs+4µs) by XML::LibXML::Error::BEGIN@42 at line 42 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@39 at line 39 of XML/LibXML/Error.pm
# once (15µs+4µs) by Template::Constants::BEGIN@51 at line 51 of Template/Constants.pm
# once (14µs+4µs) by Template::Exception::BEGIN@26 at line 26 of Template/Exception.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@36 at line 36 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@51 at line 51 of XML/LibXML/Error.pm
# once (14µs+4µs) by C4::VirtualShelves::BEGIN@30 at line 30 of C4/VirtualShelves.pm
# once (14µs+4µs) by MARC::Charset::Constants::BEGIN@45 at line 45 of MARC/Charset/Constants.pm
# once (14µs+4µs) by XML::SAX::BEGIN@23 at line 23 of XML/SAX.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@65 at line 65 of XML/LibXML/Error.pm
# once (15µs+4µs) by Template::Constants::BEGIN@76 at line 76 of Template/Constants.pm
# once (14µs+4µs) by MARC::Charset::Constants::BEGIN@32 at line 32 of MARC/Charset/Constants.pm
# once (14µs+4µs) by MARC::Charset::Constants::BEGIN@35 at line 35 of MARC/Charset/Constants.pm
# once (14µs+4µs) by XML::LibXML::BEGIN@168 at line 168 of XML/LibXML.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@43 at line 43 of XML/LibXML/Error.pm
# once (14µs+4µs) by Template::Constants::BEGIN@42 at line 42 of Template/Constants.pm
# once (14µs+4µs) by MARC::Charset::Constants::BEGIN@36 at line 36 of MARC/Charset/Constants.pm
# once (14µs+4µs) by MARC::Charset::Constants::BEGIN@47 at line 47 of MARC/Charset/Constants.pm
# once (14µs+4µs) by XML::NamespaceSupport::BEGIN@13 at line 13 of XML/NamespaceSupport.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@61 at line 61 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@48 at line 48 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@40 at line 40 of XML/LibXML/Error.pm
# once (14µs+4µs) by DateTime::BEGIN@80 at line 80 of DateTime.pm
# once (14µs+4µs) by XML::NamespaceSupport::BEGIN@16 at line 16 of XML/NamespaceSupport.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@62 at line 62 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@56 at line 56 of XML/LibXML/Error.pm
# once (14µs+4µs) by Template::Constants::BEGIN@44 at line 44 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@60 at line 60 of Template/Constants.pm
# once (14µs+4µs) by MARC::Charset::Constants::BEGIN@43 at line 43 of MARC/Charset/Constants.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@53 at line 53 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@57 at line 57 of XML/LibXML/Error.pm
# once (14µs+4µs) by Template::Constants::BEGIN@70 at line 70 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@49 at line 49 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@52 at line 52 of Template/Constants.pm
# once (14µs+4µs) by XML::LibXML::BEGIN@166 at line 166 of XML/LibXML.pm
# once (14µs+4µs) by XML::LibXML::BEGIN@177 at line 177 of XML/LibXML.pm
# once (14µs+4µs) by XML::LibXML::BEGIN@170 at line 170 of XML/LibXML.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@55 at line 55 of XML/LibXML/Error.pm
# once (14µs+4µs) by Template::Constants::BEGIN@50 at line 50 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@74 at line 74 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@64 at line 64 of Template/Constants.pm
# once (14µs+4µs) by XML::LibXML::BEGIN@165 at line 165 of XML/LibXML.pm
# once (14µs+4µs) by Template::Constants::BEGIN@79 at line 79 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@72 at line 72 of Template/Constants.pm
# once (14µs+4µs) by Time::Local::BEGIN@29 at line 29 of Time/Local.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@44 at line 44 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@64 at line 64 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@67 at line 67 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@66 at line 66 of XML/LibXML/Error.pm
# once (14µs+4µs) by Template::Constants::BEGIN@73 at line 73 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@65 at line 65 of Template/Constants.pm
# once (14µs+4µs) by MARC::Charset::Constants::BEGIN@41 at line 41 of MARC/Charset/Constants.pm
# once (14µs+4µs) by XML::LibXML::BEGIN@171 at line 171 of XML/LibXML.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@50 at line 50 of XML/LibXML/Error.pm
# once (14µs+4µs) by MARC::Charset::Constants::BEGIN@44 at line 44 of MARC/Charset/Constants.pm
# once (14µs+4µs) by XML::LibXML::BEGIN@172 at line 172 of XML/LibXML.pm
# once (14µs+4µs) by XML::LibXML::BEGIN@179 at line 179 of XML/LibXML.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@46 at line 46 of XML/LibXML/Error.pm
# once (14µs+4µs) by XML::LibXML::Error::BEGIN@54 at line 54 of XML/LibXML/Error.pm
# once (14µs+4µs) by Template::Constants::BEGIN@61 at line 61 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@69 at line 69 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@66 at line 66 of Template/Constants.pm
# once (14µs+4µs) by Template::Constants::BEGIN@58 at line 58 of Template/Constants.pm
# once (14µs+4µs) by XML::LibXML::BEGIN@178 at line 178 of XML/LibXML.pm
# once (14µs+4µs) by Template::Constants::BEGIN@80 at line 80 of Template/Constants.pm
# once (13µs+4µs) by Template::Constants::BEGIN@68 at line 68 of Template/Constants.pm
# once (13µs+4µs) by XML::LibXML::Error::BEGIN@60 at line 60 of XML/LibXML/Error.pm
# once (13µs+4µs) by Template::Constants::BEGIN@59 at line 59 of Template/Constants.pm
# once (13µs+4µs) by XML::LibXML::BEGIN@173 at line 173 of XML/LibXML.pm
# once (13µs+4µs) by XML::LibXML::BEGIN@174 at line 174 of XML/LibXML.pm
# once (13µs+3µs) by Template::Constants::BEGIN@57 at line 57 of Template/Constants.pm
# once (13µs+3µs) by Template::Constants::BEGIN@54 at line 54 of Template/Constants.pm | ||||
55 | 203 | 70µs | my $class = shift; | ||
56 | 203 | 58µs | return unless @_; # Ignore 'use constant;' | ||
57 | 203 | 22µs | my $constants; | ||
58 | 203 | 64µs | my $multiple = ref $_[0]; | ||
59 | 203 | 86µs | my $pkg = caller; | ||
60 | 203 | 23µs | my $flush_mro; | ||
61 | my $symtab; | ||||
62 | |||||
63 | 203 | 72µs | if (_CAN_PCS) { | ||
64 | 2 | 273µs | 2 | 26µs | # spent 17µs (7+10) within constant::BEGIN@64 which was called:
# once (7µs+10µs) by C4::Boolean::BEGIN@55 at line 64 # spent 17µs making 1 call to constant::BEGIN@64
# spent 10µs making 1 call to strict::unimport |
65 | 203 | 213µs | $symtab = \%{$pkg . '::'}; | ||
66 | }; | ||||
67 | |||||
68 | 203 | 70µs | if ( $multiple ) { | ||
69 | 1 | 700ns | if (ref $_[0] ne 'HASH') { | ||
70 | require Carp; | ||||
71 | Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'"); | ||||
72 | } | ||||
73 | 1 | 100ns | $constants = shift; | ||
74 | } else { | ||||
75 | 202 | 41µs | unless (defined $_[0]) { | ||
76 | require Carp; | ||||
77 | Carp::croak("Can't use undef as constant name"); | ||||
78 | } | ||||
79 | 202 | 227µs | $constants->{+shift} = undef; | ||
80 | } | ||||
81 | |||||
82 | 203 | 247µs | foreach my $name ( keys %$constants ) { | ||
83 | # Normal constant name | ||||
84 | 225 | 1.57ms | 450 | 810µs | if ($name =~ $normal_constant_name and !$forbidden{$name}) { # spent 506µs making 225 calls to constant::CORE:match, avg 2µs/call
# spent 304µs making 225 calls to constant::CORE:regcomp, avg 1µs/call |
85 | # Everything is okay | ||||
86 | |||||
87 | # Name forced into main, but we're not in main. Fatal. | ||||
88 | } elsif ($forced_into_main{$name} and $pkg ne 'main') { | ||||
89 | require Carp; | ||||
90 | Carp::croak("Constant name '$name' is forced into main::"); | ||||
91 | |||||
92 | # Starts with double underscore. Fatal. | ||||
93 | } elsif ($name =~ /^__/) { | ||||
94 | require Carp; | ||||
95 | Carp::croak("Constant name '$name' begins with '__'"); | ||||
96 | |||||
97 | # Maybe the name is tolerable | ||||
98 | } elsif ($name =~ $tolerable) { | ||||
99 | # Then we'll warn only if you've asked for warnings | ||||
100 | if (warnings::enabled()) { | ||||
101 | if ($keywords{$name}) { | ||||
102 | warnings::warn("Constant name '$name' is a Perl keyword"); | ||||
103 | } elsif ($forced_into_main{$name}) { | ||||
104 | warnings::warn("Constant name '$name' is " . | ||||
105 | "forced into package main::"); | ||||
106 | } | ||||
107 | } | ||||
108 | |||||
109 | # Looks like a boolean | ||||
110 | # use constant FRED == fred; | ||||
111 | } elsif ($name =~ $boolean) { | ||||
112 | require Carp; | ||||
113 | if (@_) { | ||||
114 | Carp::croak("Constant name '$name' is invalid"); | ||||
115 | } else { | ||||
116 | Carp::croak("Constant name looks like boolean value"); | ||||
117 | } | ||||
118 | |||||
119 | } else { | ||||
120 | # Must have bad characters | ||||
121 | require Carp; | ||||
122 | Carp::croak("Constant name '$name' has invalid characters"); | ||||
123 | } | ||||
124 | |||||
125 | { | ||||
126 | 227 | 570µs | 2 | 27µs | # spent 17µs (8+9) within constant::BEGIN@126 which was called:
# once (8µs+9µs) by C4::Boolean::BEGIN@55 at line 126 # spent 17µs making 1 call to constant::BEGIN@126
# spent 9µs making 1 call to strict::unimport |
127 | 225 | 129µs | my $full_name = "${pkg}::$name"; | ||
128 | 225 | 228µs | $declared{$full_name}++; | ||
129 | 225 | 109µs | if ($multiple || @_ == 1) { | ||
130 | 225 | 51µs | my $scalar = $multiple ? $constants->{$name} : $_[0]; | ||
131 | |||||
132 | if (_DOWNGRADE) { # for 5.8 to 5.14 | ||||
133 | # Work around perl bug #31991: Sub names (actually glob | ||||
134 | # names in general) ignore the UTF8 flag. So we have to | ||||
135 | # turn it off to get the "right" symbol table entry. | ||||
136 | utf8::is_utf8 $name and utf8::encode $name; | ||||
137 | } | ||||
138 | |||||
139 | # The constant serves to optimise this entire block out on | ||||
140 | # 5.8 and earlier. | ||||
141 | 225 | 45µs | if (_CAN_PCS) { | ||
142 | # Use a reference as a proxy for a constant subroutine. | ||||
143 | # If this is not a glob yet, it saves space. If it is | ||||
144 | # a glob, we must still create it this way to get the | ||||
145 | # right internal flags set, as constants are distinct | ||||
146 | # from subroutines created with sub(){...}. | ||||
147 | # The check in Perl_ck_rvconst knows that inlinable | ||||
148 | # constants from cv_const_sv are read only. So we have to: | ||||
149 | 225 | 493µs | 225 | 145µs | Internals::SvREADONLY($scalar, 1); # spent 145µs making 225 calls to Internals::SvREADONLY, avg 646ns/call |
150 | 225 | 147µs | if ($symtab && !exists $symtab->{$name}) { | ||
151 | 222 | 109µs | $symtab->{$name} = \$scalar; | ||
152 | 222 | 34µs | ++$flush_mro; | ||
153 | } | ||||
154 | else { | ||||
155 | 3 | 3µs | local $constant::{_dummy} = \$scalar; | ||
156 | 3 | 10µs | *$full_name = \&{"_dummy"}; | ||
157 | } | ||||
158 | } else { | ||||
159 | *$full_name = sub () { $scalar }; | ||||
160 | } | ||||
161 | } elsif (@_) { | ||||
162 | my @list = @_; | ||||
163 | if (_CAN_PCS_FOR_ARRAY) { | ||||
164 | _make_const($list[$_]) for 0..$#list; | ||||
165 | _make_const(@list); | ||||
166 | if ($symtab && !exists $symtab->{$name}) { | ||||
167 | $symtab->{$name} = \@list; | ||||
168 | $flush_mro++; | ||||
169 | } | ||||
170 | else { | ||||
171 | local $constant::{_dummy} = \@list; | ||||
172 | *$full_name = \&{"_dummy"}; | ||||
173 | } | ||||
174 | } | ||||
175 | else { *$full_name = sub () { @list }; } | ||||
176 | } else { | ||||
177 | *$full_name = sub () { }; | ||||
178 | } | ||||
179 | } | ||||
180 | } | ||||
181 | # Flush the cache exactly once if we make any direct symbol table changes. | ||||
182 | 203 | 1.32ms | 200 | 225µs | mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro; # spent 225µs making 200 calls to mro::method_changed_in, avg 1µs/call |
183 | } | ||||
184 | |||||
185 | 1 | 7µs | 1; | ||
186 | |||||
187 | __END__ | ||||
# spent 506µs within constant::CORE:match which was called 225 times, avg 2µs/call:
# 225 times (506µs+0s) by constant::import at line 84, avg 2µs/call | |||||
sub constant::CORE:qr; # opcode | |||||
# spent 304µs within constant::CORE:regcomp which was called 225 times, avg 1µs/call:
# 225 times (304µs+0s) by constant::import at line 84, avg 1µs/call |