Filename | /usr/share/perl/5.10/base.pm |
Statements | Executed 1540 statements in 7.93ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
55 | 55 | 46 | 31.1ms | 41.9ms | import (recurses: max depth 2, inclusive time 3.25ms) | base::
56 | 1 | 1 | 598µs | 598µs | has_version | base::
56 | 1 | 1 | 374µs | 374µs | has_fields | base::
56 | 1 | 1 | 271µs | 271µs | has_attr | base::
8 | 1 | 1 | 66µs | 66µs | CORE:match (opcode) | base::
1 | 1 | 1 | 26µs | 53µs | BEGIN@3 | base::
1 | 1 | 1 | 20µs | 78µs | BEGIN@4 | base::
0 | 0 | 0 | 0s | 0s | __ANON__[:53] | base::
0 | 0 | 0 | 0s | 0s | __ANON__[:60] | base::
0 | 0 | 0 | 0s | 0s | get_attr | base::
0 | 0 | 0 | 0s | 0s | inherit_fields | base::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package base; | ||||
2 | |||||
3 | 3 | 52µs | 2 | 81µs | # spent 53µs (26+28) within base::BEGIN@3 which was called:
# once (26µs+28µs) by C4::Boolean::BEGIN@28 at line 3 # spent 53µs making 1 call to base::BEGIN@3
# spent 28µs making 1 call to strict::import |
4 | 3 | 1.58ms | 2 | 135µs | # spent 78µs (20+58) within base::BEGIN@4 which was called:
# once (20µs+58µs) by C4::Boolean::BEGIN@28 at line 4 # spent 78µs making 1 call to base::BEGIN@4
# spent 58µs making 1 call to vars::import |
5 | 1 | 1µs | $VERSION = '2.14'; | ||
6 | 1 | 32µs | $VERSION = eval $VERSION; # spent 5µs executing statements in string eval | ||
7 | |||||
8 | # constant.pm is slow | ||||
9 | sub SUCCESS () { 1 } | ||||
10 | |||||
11 | sub PUBLIC () { 2**0 } | ||||
12 | sub PRIVATE () { 2**1 } | ||||
13 | sub INHERITED () { 2**2 } | ||||
14 | sub PROTECTED () { 2**3 } | ||||
15 | |||||
16 | 1 | 2µs | my $Fattr = \%fields::attr; | ||
17 | |||||
18 | # spent 374µs within base::has_fields which was called 56 times, avg 7µs/call:
# 56 times (374µs+0s) by base::import at line 112, avg 7µs/call | ||||
19 | 168 | 437µs | my($base) = shift; | ||
20 | my $fglob = ${"$base\::"}{FIELDS}; | ||||
21 | return( ($fglob && 'GLOB' eq ref($fglob) && *$fglob{HASH}) ? 1 : 0 ); | ||||
22 | } | ||||
23 | |||||
24 | # spent 598µs within base::has_version which was called 56 times, avg 11µs/call:
# 56 times (598µs+0s) by base::import at line 82, avg 11µs/call | ||||
25 | 168 | 654µs | my($base) = shift; | ||
26 | my $vglob = ${$base.'::'}{VERSION}; | ||||
27 | return( ($vglob && *$vglob{SCALAR}) ? 1 : 0 ); | ||||
28 | } | ||||
29 | |||||
30 | # spent 271µs within base::has_attr which was called 56 times, avg 5µs/call:
# 56 times (271µs+0s) by base::import at line 112, avg 5µs/call | ||||
31 | 168 | 313µs | my($proto) = shift; | ||
32 | my($class) = ref $proto || $proto; | ||||
33 | return exists $Fattr->{$class}; | ||||
34 | } | ||||
35 | |||||
36 | sub get_attr { | ||||
37 | $Fattr->{$_[0]} = [1] unless $Fattr->{$_[0]}; | ||||
38 | return $Fattr->{$_[0]}; | ||||
39 | } | ||||
40 | |||||
41 | 1 | 4µs | if ($] < 5.009) { | ||
42 | *get_fields = sub { | ||||
43 | # Shut up a possible typo warning. | ||||
44 | () = \%{$_[0].'::FIELDS'}; | ||||
45 | my $f = \%{$_[0].'::FIELDS'}; | ||||
46 | |||||
47 | # should be centralized in fields? perhaps | ||||
48 | # fields::mk_FIELDS_be_OK. Peh. As long as %{ $package . '::FIELDS' } | ||||
49 | # is used here anyway, it doesn't matter. | ||||
50 | bless $f, 'pseudohash' if (ref($f) ne 'pseudohash'); | ||||
51 | |||||
52 | return $f; | ||||
53 | } | ||||
54 | } | ||||
55 | else { | ||||
56 | *get_fields = sub { | ||||
57 | # Shut up a possible typo warning. | ||||
58 | () = \%{$_[0].'::FIELDS'}; | ||||
59 | return \%{$_[0].'::FIELDS'}; | ||||
60 | } | ||||
61 | 1 | 7µs | } | ||
62 | |||||
63 | # spent 41.9ms (31.1+10.8) within base::import which was called 55 times, avg 762µs/call:
# once (13.9ms+773µs) by Koha::QueryParser::Driver::PQF::BEGIN@2 at line 2 of /usr/share/koha/lib/Koha/QueryParser/Driver/PQF.pm
# once (5.42ms+613µs) by Set::Infinite::BEGIN@16 at line 16 of Set/Infinite.pm
# once (1.05ms+3.83ms) by DateTime::TimeZone::Floating::BEGIN@9 at line 9 of DateTime/TimeZone/Floating.pm
# once (1.98ms+2.82ms) by DateTime::Locale::en_US::BEGIN@25 at line 25 of DateTime/Locale/en_US.pm
# once (872µs+3.69ms) by Template::BEGIN@25 at line 25 of Template.pm
# once (1.77ms+678µs) by C4::Templates::BEGIN@32 at line 32 of /usr/share/koha/lib/C4/Templates.pm
# once (251µs+40µs) by Authen::CAS::Client::Response::AuthFailure::BEGIN@68 at line 68 of Authen/CAS/Client/Response.pm
# once (222µs+37µs) by Authen::CAS::Client::Response::AuthSuccess::BEGIN@94 at line 94 of Authen/CAS/Client/Response.pm
# once (177µs+33µs) by Koha::QueryParser::Driver::PQF::query_plan::BEGIN@2 at line 2 of /usr/share/koha/lib/Koha/QueryParser/Driver/PQF/query_plan.pm
# once (158µs+46µs) by Template::Parser::BEGIN@37 at line 37 of Template/Parser.pm
# once (137µs+27µs) by Koha::QueryParser::Driver::PQF::query_plan::node::atom::BEGIN@2 at line 2 of /usr/share/koha/lib/Koha/QueryParser/Driver/PQF/query_plan/node/atom.pm
# once (136µs+24µs) by Koha::QueryParser::Driver::PQF::query_plan::facet::BEGIN@2 at line 2 of /usr/share/koha/lib/Koha/QueryParser/Driver/PQF/query_plan/facet.pm
# once (136µs+22µs) by Koha::QueryParser::Driver::PQF::query_plan::node::BEGIN@2 at line 2 of /usr/share/koha/lib/Koha/QueryParser/Driver/PQF/query_plan/node.pm
# once (134µs+22µs) by Koha::QueryParser::Driver::PQF::query_plan::modifier::BEGIN@2 at line 2 of /usr/share/koha/lib/Koha/QueryParser/Driver/PQF/query_plan/modifier.pm
# once (128µs+23µs) by Koha::QueryParser::Driver::PQF::query_plan::filter::BEGIN@2 at line 2 of /usr/share/koha/lib/Koha/QueryParser/Driver/PQF/query_plan/filter.pm
# once (80µs+47µs) by Business::ISBN10::BEGIN@5 at line 5 of Business/ISBN10.pm
# once (101µs+23µs) by MARC::File::XML::BEGIN@6 at line 6 of MARC/File/XML.pm
# once (80µs+42µs) by Template::Directive::BEGIN@31 at line 31 of Template/Directive.pm
# once (85µs+34µs) by C4::Boolean::BEGIN@28 at line 28 of /usr/share/koha/lib/C4/Boolean.pm
# once (86µs+30µs) by Authen::CAS::Client::Response::Failure::BEGIN@53 at line 53 of Authen/CAS/Client/Response.pm
# once (84µs+28µs) by Authen::CAS::Client::Response::Error::BEGIN@39 at line 39 of Authen/CAS/Client/Response.pm
# once (78µs+31µs) by Authen::CAS::Client::Response::Success::BEGIN@84 at line 84 of Authen/CAS/Client/Response.pm
# once (71µs+31µs) by Authen::CAS::Client::Response::ProxyFailure::BEGIN@76 at line 76 of Authen/CAS/Client/Response.pm
# once (64µs+31µs) by Business::ISBN::BEGIN@73 at line 73 of Business/ISBN.pm
# once (65µs+29µs) by Authen::CAS::Client::Response::ProxySuccess::BEGIN@108 at line 108 of Authen/CAS/Client/Response.pm
# once (60µs+29µs) by MARC::Charset::Code::BEGIN@5 at line 5 of MARC/Charset/Code.pm
# once (58µs+31µs) by Template::Context::BEGIN@25 at line 25 of Template/Context.pm
# once (58µs+30µs) by C4::Linker::BEGIN@50 at line 50 of /usr/share/koha/lib/C4/Linker.pm
# once (58µs+26µs) by JSON::BEGIN@6 at line 6 of JSON.pm
# once (53µs+29µs) by Template::Iterator::BEGIN@26 at line 26 of Template/Iterator.pm
# once (56µs+26µs) by MARC::File::Encode::BEGIN@21 at line 21 of MARC/File/Encode.pm
# once (56µs+25µs) by Template::Plugins::BEGIN@28 at line 28 of Template/Plugins.pm
# once (52µs+27µs) by DateTime::Format::Builder::Parser::Quick::BEGIN@5 at line 5 of DateTime/Format/Builder/Parser/Quick.pm
# once (51µs+25µs) by DateTime::Infinite::BEGIN@12 at line 12 of DateTime/Infinite.pm
# once (49µs+25µs) by Koha::DateUtils::BEGIN@26 at line 26 of /usr/share/koha/lib/Koha/DateUtils.pm
# once (47µs+25µs) by JSON::PP::BEGIN@7 at line 7 of JSON/PP.pm
# once (43µs+27µs) by Template::Service::BEGIN@25 at line 25 of Template/Service.pm
# once (45µs+19µs) by Business::ISBN13::BEGIN@5 at line 5 of Business/ISBN13.pm
# once (44µs+18µs) by Encode::Alias::BEGIN@8 at line 8 of Encode/Alias.pm
# once (38µs+23µs) by MARC::File::SAX::BEGIN@11 at line 11 of MARC/File/SAX.pm
# once (42µs+19µs) by Template::Filters::BEGIN@25 at line 25 of Template/Filters.pm
# once (41µs+19µs) by Template::Config::BEGIN@23 at line 23 of Template/Config.pm
# once (37µs+18µs) by Template::Provider::BEGIN@43 at line 43 of Template/Provider.pm
# once (40µs+15µs) by DateTime::Infinite::Future::BEGIN@46 at line 46 of DateTime/Infinite.pm
# once (39µs+15µs) by MARC::Charset::BEGIN@7 at line 7 of MARC/Charset.pm
# once (38µs+14µs) by DateTime::Infinite::Past::BEGIN@70 at line 70 of DateTime/Infinite.pm
# once (34µs+15µs) by MARC::Charset::Constants::BEGIN@20 at line 20 of MARC/Charset/Constants.pm
# once (34µs+14µs) by Encode::BEGIN@13 at line 13 of Encode.pm
# once (32µs+14µs) by Template::Document::BEGIN@26 at line 26 of Template/Document.pm
# once (29µs+-29µs) by Sub::Name::BEGIN@50 at line 50 of Sub/Name.pm
# once (43µs+-43µs) by Sub::Name::BEGIN@49 at line 49 of Sub/Name.pm
# once (174µs+-174µs) by DateTime::Locale::root::BEGIN@25 at line 25 of DateTime/Locale/root.pm
# once (96µs+-96µs) by DateTime::TimeZone::OffsetOnly::BEGIN@9 at line 9 of DateTime/TimeZone/OffsetOnly.pm
# once (2.38ms+-2.38ms) by DateTime::Locale::en::BEGIN@25 at line 25 of DateTime/Locale/en.pm
# once (65µs+-65µs) by DateTime::TimeZone::UTC::BEGIN@9 at line 9 of DateTime/TimeZone/UTC.pm | ||||
64 | 1024 | 4.84ms | my $class = shift; | ||
65 | |||||
66 | return SUCCESS unless @_; | ||||
67 | |||||
68 | # List of base classes from which we will inherit %FIELDS. | ||||
69 | my $fields_base; | ||||
70 | |||||
71 | my $inheritor = caller(0); | ||||
72 | my @isa_classes; | ||||
73 | |||||
74 | my @bases; | ||||
75 | foreach my $base (@_) { | ||||
76 | if ( $inheritor eq $base ) { | ||||
77 | warn "Class '$inheritor' tried to inherit from itself\n"; | ||||
78 | } | ||||
79 | |||||
80 | 59 | 224µs | next if grep $_->isa($base), ($inheritor, @bases); # spent 224µs making 59 calls to UNIVERSAL::isa, avg 4µs/call | ||
81 | |||||
82 | 56 | 598µs | if (has_version($base)) { # spent 598µs making 56 calls to base::has_version, avg 11µs/call | ||
83 | ${$base.'::VERSION'} = '-1, set by base.pm' | ||||
84 | unless defined ${$base.'::VERSION'}; | ||||
85 | } | ||||
86 | else { | ||||
87 | my $sigdie; | ||||
88 | { | ||||
89 | local $SIG{__DIE__}; | ||||
90 | eval "require $base"; # spent 128µs executing statements in string eval
# spent 100µs executing statements in string eval
# spent 99µs executing statements in string eval
# spent 98µs executing statements in string eval
# spent 98µs executing statements in string eval
# spent 96µs executing statements in string eval
# spent 91µs executing statements in string eval
# spent 86µs executing statements in string eval
# spent 70µs executing statements in string eval
# spent 65µs executing statements in string eval
# spent 49µs executing statements in string eval
# spent 41µs executing statements in string eval
# spent 40µs executing statements in string eval
# spent 39µs executing statements in string eval
# spent 38µs executing statements in string eval
# spent 6µs executing statements in string eval
# spent 3µs executing statements in string eval | ||||
91 | # Only ignore "Can't locate" errors from our eval require. | ||||
92 | # Other fatal errors (syntax etc) must be reported. | ||||
93 | 8 | 66µs | die if $@ && $@ !~ /^Can't locate .*? at \(eval /; # spent 66µs making 8 calls to base::CORE:match, avg 8µs/call | ||
94 | unless (%{"$base\::"}) { | ||||
95 | require Carp; | ||||
96 | local $" = " "; | ||||
97 | Carp::croak(<<ERROR); | ||||
98 | Base class package "$base" is empty. | ||||
99 | (Perhaps you need to 'use' the module which defines that package first, | ||||
100 | or make that module available in \@INC (\@INC contains: @INC). | ||||
101 | ERROR | ||||
102 | } | ||||
103 | $sigdie = $SIG{__DIE__} || undef; | ||||
104 | } | ||||
105 | # Make sure a global $SIG{__DIE__} makes it out of the localization. | ||||
106 | $SIG{__DIE__} = $sigdie if defined $sigdie; | ||||
107 | ${$base.'::VERSION'} = "-1, set by base.pm" | ||||
108 | unless defined ${$base.'::VERSION'}; | ||||
109 | } | ||||
110 | push @bases, $base; | ||||
111 | |||||
112 | 112 | 644µs | if ( has_fields($base) || has_attr($base) ) { # spent 374µs making 56 calls to base::has_fields, avg 7µs/call
# spent 271µs making 56 calls to base::has_attr, avg 5µs/call | ||
113 | # No multiple fields inheritance *suck* | ||||
114 | if ($fields_base) { | ||||
115 | require Carp; | ||||
116 | Carp::croak("Can't multiply inherit fields"); | ||||
117 | } else { | ||||
118 | $fields_base = $base; | ||||
119 | } | ||||
120 | } | ||||
121 | } | ||||
122 | # Save this until the end so it's all or nothing if the above loop croaks. | ||||
123 | push @{"$inheritor\::ISA"}, @isa_classes; | ||||
124 | |||||
125 | push @{"$inheritor\::ISA"}, @bases; | ||||
126 | |||||
127 | if( defined $fields_base ) { | ||||
128 | inherit_fields($inheritor, $fields_base); | ||||
129 | } | ||||
130 | } | ||||
131 | |||||
132 | sub inherit_fields { | ||||
133 | my($derived, $base) = @_; | ||||
134 | |||||
135 | return SUCCESS unless $base; | ||||
136 | |||||
137 | my $battr = get_attr($base); | ||||
138 | my $dattr = get_attr($derived); | ||||
139 | my $dfields = get_fields($derived); | ||||
140 | my $bfields = get_fields($base); | ||||
141 | |||||
142 | $dattr->[0] = @$battr; | ||||
143 | |||||
144 | if( keys %$dfields ) { | ||||
145 | warn <<"END"; | ||||
146 | $derived is inheriting from $base but already has its own fields! | ||||
147 | This will cause problems. Be sure you use base BEFORE declaring fields. | ||||
148 | END | ||||
149 | |||||
150 | } | ||||
151 | |||||
152 | # Iterate through the base's fields adding all the non-private | ||||
153 | # ones to the derived class. Hang on to the original attribute | ||||
154 | # (Public, Private, etc...) and add Inherited. | ||||
155 | # This is all too complicated to do efficiently with add_fields(). | ||||
156 | while (my($k,$v) = each %$bfields) { | ||||
157 | my $fno; | ||||
158 | if ($fno = $dfields->{$k} and $fno != $v) { | ||||
159 | require Carp; | ||||
160 | Carp::croak ("Inherited fields can't override existing fields"); | ||||
161 | } | ||||
162 | |||||
163 | if( $battr->[$v] & PRIVATE ) { | ||||
164 | $dattr->[$v] = PRIVATE | INHERITED; | ||||
165 | } | ||||
166 | else { | ||||
167 | $dattr->[$v] = INHERITED | $battr->[$v]; | ||||
168 | $dfields->{$k} = $v; | ||||
169 | } | ||||
170 | } | ||||
171 | |||||
172 | foreach my $idx (1..$#{$battr}) { | ||||
173 | next if defined $dattr->[$idx]; | ||||
174 | $dattr->[$idx] = $battr->[$idx] & INHERITED; | ||||
175 | } | ||||
176 | } | ||||
177 | |||||
178 | 1 | 8µs | 1; | ||
179 | |||||
180 | __END__ | ||||
# spent 66µs within base::CORE:match which was called 8 times, avg 8µs/call:
# 8 times (66µs+0s) by base::import at line 93, avg 8µs/call |