Filename | /usr/share/perl/5.10/base.pm |
Statements | Executed 1573 statements in 7.64ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
56 | 56 | 47 | 54.7ms | 64.9ms | import (recurses: max depth 2, inclusive time 2.93ms) | base::
57 | 1 | 1 | 632µs | 632µs | has_version | base::
57 | 1 | 1 | 434µs | 434µs | has_attr | base::
57 | 1 | 1 | 371µs | 371µs | has_fields | base::
8 | 1 | 1 | 56µs | 56µs | CORE:match (opcode) | base::
1 | 1 | 1 | 26µs | 54µs | BEGIN@3 | base::
1 | 1 | 1 | 17µs | 77µ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 | 70µs | 2 | 81µs | # spent 54µs (26+27) within base::BEGIN@3 which was called:
# once (26µs+27µs) by Encode::BEGIN@13 at line 3 # spent 54µs making 1 call to base::BEGIN@3
# spent 27µs making 1 call to strict::import |
4 | 3 | 1.21ms | 2 | 137µs | # spent 77µs (17+60) within base::BEGIN@4 which was called:
# once (17µs+60µs) by Encode::BEGIN@13 at line 4 # spent 77µs making 1 call to base::BEGIN@4
# spent 60µs making 1 call to vars::import |
5 | 1 | 800ns | $VERSION = '2.14'; | ||
6 | 1 | 20µs | $VERSION = eval $VERSION; # spent 4µ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 | 1µs | my $Fattr = \%fields::attr; | ||
17 | |||||
18 | # spent 371µs within base::has_fields which was called 57 times, avg 7µs/call:
# 57 times (371µs+0s) by base::import at line 112, avg 7µs/call | ||||
19 | 57 | 59µs | my($base) = shift; | ||
20 | 57 | 121µs | my $fglob = ${"$base\::"}{FIELDS}; | ||
21 | 57 | 268µs | return( ($fglob && 'GLOB' eq ref($fglob) && *$fglob{HASH}) ? 1 : 0 ); | ||
22 | } | ||||
23 | |||||
24 | # spent 632µs within base::has_version which was called 57 times, avg 11µs/call:
# 57 times (632µs+0s) by base::import at line 82, avg 11µs/call | ||||
25 | 57 | 79µs | my($base) = shift; | ||
26 | 57 | 247µs | my $vglob = ${$base.'::'}{VERSION}; | ||
27 | 57 | 358µs | return( ($vglob && *$vglob{SCALAR}) ? 1 : 0 ); | ||
28 | } | ||||
29 | |||||
30 | # spent 434µs within base::has_attr which was called 57 times, avg 8µs/call:
# 57 times (434µs+0s) by base::import at line 112, avg 8µs/call | ||||
31 | 57 | 62µs | my($proto) = shift; | ||
32 | 57 | 56µs | my($class) = ref $proto || $proto; | ||
33 | 57 | 355µs | 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 | 2µ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 | 4µs | } | ||
62 | |||||
63 | # spent 64.9ms (54.7+10.2) within base::import which was called 56 times, avg 1.16ms/call:
# once (19.1ms+587µs) by Koha::QueryParser::Driver::PQF::BEGIN@2 at line 2 of /usr/share/koha/lib/Koha/QueryParser/Driver/PQF.pm
# once (17.0ms+107µs) by MARC::File::SAX::BEGIN@11 at line 11 of MARC/File/SAX.pm
# once (5.48ms+637µs) by Set::Infinite::BEGIN@16 at line 16 of Set/Infinite.pm
# once (3.39ms+2.60ms) by DateTime::Locale::en_US::BEGIN@25 at line 25 of DateTime/Locale/en_US.pm
# once (886µs+4.29ms) by Template::BEGIN@25 at line 25 of Template.pm
# once (700µs+2.45ms) by DateTime::TimeZone::Floating::BEGIN@9 at line 9 of DateTime/TimeZone/Floating.pm
# once (2.04ms+784µs) by C4::Templates::BEGIN@32 at line 32 of /usr/share/koha/lib/C4/Templates.pm
# once (292µs+44µs) by Authen::CAS::Client::Response::AuthSuccess::BEGIN@94 at line 94 of Authen/CAS/Client/Response.pm
# once (199µs+32µ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 (190µs+34µ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 (178µs+23µ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 (153µs+27µs) by Authen::CAS::Client::Response::AuthFailure::BEGIN@68 at line 68 of Authen/CAS/Client/Response.pm
# once (151µs+26µ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 (109µs+55µs) by Authen::CAS::Client::Response::ProxySuccess::BEGIN@108 at line 108 of Authen/CAS/Client/Response.pm
# once (57µs+106µs) by Template::Parser::BEGIN@37 at line 37 of Template/Parser.pm
# once (134µs+22µ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 (127µs+21µ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 (90µs+56µs) by C4::Linker::BEGIN@50 at line 50 of /usr/share/koha/lib/C4/Linker.pm
# once (101µs+32µs) by Business::ISBN10::BEGIN@5 at line 5 of Business/ISBN10.pm
# once (74µs+45µs) by JSON::BEGIN@6 at line 6 of JSON.pm
# once (97µs+19µs) by Template::Directive::BEGIN@31 at line 31 of Template/Directive.pm
# once (72µs+36µs) by MARC::File::Encode::BEGIN@21 at line 21 of MARC/File/Encode.pm
# once (68µs+37µs) by C4::Boolean::BEGIN@28 at line 28 of /usr/share/koha/lib/C4/Boolean.pm
# once (90µs+15µs) by MARC::File::XML::BEGIN@6 at line 6 of MARC/File/XML.pm
# once (61µs+34µs) by Template::Service::BEGIN@25 at line 25 of Template/Service.pm
# once (67µs+26µs) by Encode::BEGIN@13 at line 13 of Encode.pm
# once (65µs+28µs) by Authen::CAS::Client::Response::Error::BEGIN@39 at line 39 of Authen/CAS/Client/Response.pm
# once (60µs+31µs) by Authen::CAS::Client::Response::Failure::BEGIN@53 at line 53 of Authen/CAS/Client/Response.pm
# once (62µs+29µs) by DateTime::Infinite::BEGIN@12 at line 12 of DateTime/Infinite.pm
# once (53µs+35µs) by MARC::Charset::Code::BEGIN@5 at line 5 of MARC/Charset/Code.pm
# once (58µs+29µs) by Template::Filters::BEGIN@25 at line 25 of Template/Filters.pm
# once (57µs+29µs) by Template::Context::BEGIN@25 at line 25 of Template/Context.pm
# once (57µs+29µs) by Template::Plugins::BEGIN@28 at line 28 of Template/Plugins.pm
# once (55µs+31µs) by Koha::DateUtils::BEGIN@26 at line 26 of /usr/share/koha/lib/Koha/DateUtils.pm
# once (55µs+29µs) by Template::Iterator::BEGIN@26 at line 26 of Template/Iterator.pm
# once (58µs+26µs) by Authen::CAS::Client::Response::ProxyFailure::BEGIN@76 at line 76 of Authen/CAS/Client/Response.pm
# once (53µs+27µs) by DateTime::Format::Builder::Parser::Quick::BEGIN@5 at line 5 of DateTime/Format/Builder/Parser/Quick.pm
# once (56µs+23µs) by DateTime::Infinite::Future::BEGIN@46 at line 46 of DateTime/Infinite.pm
# once (52µs+27µs) by Encode::Alias::BEGIN@8 at line 8 of Encode/Alias.pm
# once (49µs+28µs) by Business::ISBN::BEGIN@73 at line 73 of Business/ISBN.pm
# once (52µs+23µs) by Authen::CAS::Client::Response::Success::BEGIN@84 at line 84 of Authen/CAS/Client/Response.pm
# once (50µs+25µs) by MARC::Charset::BEGIN@7 at line 7 of MARC/Charset.pm
# once (47µs+28µs) by JSON::PP::BEGIN@7 at line 7 of JSON/PP.pm
# once (39µs+26µs) by Memoize::Memcached::BEGIN@17 at line 17 of Memoize/Memcached.pm
# once (40µs+20µs) by Template::Config::BEGIN@23 at line 23 of Template/Config.pm
# once (36µs+19µs) by MARC::Charset::Constants::BEGIN@20 at line 20 of MARC/Charset/Constants.pm
# once (36µs+17µs) by Business::ISBN13::BEGIN@5 at line 5 of Business/ISBN13.pm
# once (36µs+15µs) by DateTime::Infinite::Past::BEGIN@70 at line 70 of DateTime/Infinite.pm
# once (32µs+16µs) by Template::Provider::BEGIN@43 at line 43 of Template/Provider.pm
# once (31µs+14µs) by Template::Document::BEGIN@26 at line 26 of Template/Document.pm
# once (51µs+-51µs) by DateTime::TimeZone::OffsetOnly::BEGIN@9 at line 9 of DateTime/TimeZone/OffsetOnly.pm
# once (46µs+-46µs) by DateTime::TimeZone::UTC::BEGIN@9 at line 9 of DateTime/TimeZone/UTC.pm
# once (69µs+-69µs) by Sub::Name::BEGIN@50 at line 50 of Sub/Name.pm
# once (53µs+-53µs) by Sub::Name::BEGIN@49 at line 49 of Sub/Name.pm
# once (2.30ms+-2.30ms) by DateTime::Locale::en::BEGIN@25 at line 25 of DateTime/Locale/en.pm
# once (95µs+-95µs) by DateTime::Locale::root::BEGIN@25 at line 25 of DateTime/Locale/root.pm | ||||
64 | 56 | 77µs | my $class = shift; | ||
65 | |||||
66 | 56 | 36µs | return SUCCESS unless @_; | ||
67 | |||||
68 | # List of base classes from which we will inherit %FIELDS. | ||||
69 | 56 | 19µs | my $fields_base; | ||
70 | |||||
71 | 56 | 64µs | my $inheritor = caller(0); | ||
72 | 56 | 19µs | my @isa_classes; | ||
73 | |||||
74 | 56 | 21µs | my @bases; | ||
75 | 56 | 96µs | foreach my $base (@_) { | ||
76 | 58 | 40µs | if ( $inheritor eq $base ) { | ||
77 | warn "Class '$inheritor' tried to inherit from itself\n"; | ||||
78 | } | ||||
79 | |||||
80 | 58 | 1.21ms | 60 | 291µs | next if grep $_->isa($base), ($inheritor, @bases); # spent 291µs making 60 calls to UNIVERSAL::isa, avg 5µs/call |
81 | |||||
82 | 57 | 203µs | 57 | 632µs | if (has_version($base)) { # spent 632µs making 57 calls to base::has_version, avg 11µs/call |
83 | ${$base.'::VERSION'} = '-1, set by base.pm' | ||||
84 | 39 | 103µs | unless defined ${$base.'::VERSION'}; | ||
85 | } | ||||
86 | else { | ||||
87 | 18 | 8µs | my $sigdie; | ||
88 | { | ||||
89 | 36 | 129µs | local $SIG{__DIE__}; | ||
90 | 18 | 578µs | eval "require $base"; # spent 125µs executing statements in string eval
# spent 120µs executing statements in string eval
# spent 100µs executing statements in string eval
# spent 99µs executing statements in string eval
# spent 99µs executing statements in string eval
# spent 98µs executing statements in string eval
# spent 96µs executing statements in string eval
# spent 96µs executing statements in string eval
# spent 88µs executing statements in string eval
# spent 71µs executing statements in string eval
# spent 70µs executing statements in string eval
# spent 54µs executing statements in string eval
# spent 52µs executing statements in string eval
# spent 45µs executing statements in string eval
# spent 38µs executing statements in string eval
# spent 37µs executing statements in string eval
# spent 4µ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 | 18 | 124µs | 8 | 56µs | die if $@ && $@ !~ /^Can't locate .*? at \(eval /; # spent 56µs making 8 calls to base::CORE:match, avg 7µs/call |
94 | 18 | 95µs | 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 | 18 | 118µs | $sigdie = $SIG{__DIE__} || undef; | ||
104 | } | ||||
105 | # Make sure a global $SIG{__DIE__} makes it out of the localization. | ||||
106 | 18 | 11µs | $SIG{__DIE__} = $sigdie if defined $sigdie; | ||
107 | ${$base.'::VERSION'} = "-1, set by base.pm" | ||||
108 | 18 | 109µs | unless defined ${$base.'::VERSION'}; | ||
109 | } | ||||
110 | 57 | 73µs | push @bases, $base; | ||
111 | |||||
112 | 57 | 390µs | 114 | 805µs | if ( has_fields($base) || has_attr($base) ) { # spent 434µs making 57 calls to base::has_attr, avg 8µs/call
# spent 371µs making 57 calls to base::has_fields, avg 7µ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 | 56 | 266µs | push @{"$inheritor\::ISA"}, @isa_classes; | ||
124 | |||||
125 | 56 | 534µs | push @{"$inheritor\::ISA"}, @bases; | ||
126 | |||||
127 | 56 | 401µs | 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 | 6µs | 1; | ||
179 | |||||
180 | __END__ | ||||
# spent 56µs within base::CORE:match which was called 8 times, avg 7µs/call:
# 8 times (56µs+0s) by base::import at line 93, avg 7µs/call |