← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:12:17 2013

Filename/usr/share/perl/5.10/base.pm
StatementsExecuted 1573 statements in 7.64ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
56564754.7ms64.9msbase::::importbase::import (recurses: max depth 2, inclusive time 2.93ms)
5711632µs632µsbase::::has_versionbase::has_version
5711434µs434µsbase::::has_attrbase::has_attr
5711371µs371µsbase::::has_fieldsbase::has_fields
81156µs56µsbase::::CORE:matchbase::CORE:match (opcode)
11126µs54µsbase::::BEGIN@3base::BEGIN@3
11117µs77µsbase::::BEGIN@4base::BEGIN@4
0000s0sbase::::__ANON__[:53]base::__ANON__[:53]
0000s0sbase::::__ANON__[:60]base::__ANON__[:60]
0000s0sbase::::get_attrbase::get_attr
0000s0sbase::::inherit_fieldsbase::inherit_fields
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package base;
2
3370µs281µ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
use strict 'vars';
# spent 54µs making 1 call to base::BEGIN@3 # spent 27µs making 1 call to strict::import
431.21ms2137µ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
use vars qw($VERSION);
# spent 77µs making 1 call to base::BEGIN@4 # spent 60µs making 1 call to vars::import
51800ns$VERSION = '2.14';
6120µs$VERSION = eval $VERSION;
# spent 4µs executing statements in string eval
7
8# constant.pm is slow
9sub SUCCESS () { 1 }
10
11sub PUBLIC () { 2**0 }
12sub PRIVATE () { 2**1 }
13sub INHERITED () { 2**2 }
14sub PROTECTED () { 2**3 }
15
1611µsmy $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
sub has_fields {
195759µs my($base) = shift;
2057121µs my $fglob = ${"$base\::"}{FIELDS};
2157268µ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
sub has_version {
255779µs my($base) = shift;
2657247µs my $vglob = ${$base.'::'}{VERSION};
2757358µ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
sub has_attr {
315762µs my($proto) = shift;
325756µs my($class) = ref $proto || $proto;
3357355µs return exists $Fattr->{$class};
34}
35
36sub get_attr {
37 $Fattr->{$_[0]} = [1] unless $Fattr->{$_[0]};
38 return $Fattr->{$_[0]};
39}
40
4112µsif ($] < 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}
55else {
56 *get_fields = sub {
57 # Shut up a possible typo warning.
58 () = \%{$_[0].'::FIELDS'};
59 return \%{$_[0].'::FIELDS'};
60 }
6114µ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
sub import {
645677µs my $class = shift;
65
665636µs return SUCCESS unless @_;
67
68 # List of base classes from which we will inherit %FIELDS.
695619µs my $fields_base;
70
715664µs my $inheritor = caller(0);
725619µs my @isa_classes;
73
745621µs my @bases;
755696µs foreach my $base (@_) {
765840µs if ( $inheritor eq $base ) {
77 warn "Class '$inheritor' tried to inherit from itself\n";
78 }
79
80581.21ms60291µs next if grep $_->isa($base), ($inheritor, @bases);
# spent 291µs making 60 calls to UNIVERSAL::isa, avg 5µs/call
81
8257203µs57632µ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'
8439103µs unless defined ${$base.'::VERSION'};
85 }
86 else {
87188µs my $sigdie;
88 {
8936129µs local $SIG{__DIE__};
9018578µ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.
9318124µs856µs die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
# spent 56µs making 8 calls to base::CORE:match, avg 7µs/call
941895µs unless (%{"$base\::"}) {
95 require Carp;
96 local $" = " ";
97 Carp::croak(<<ERROR);
98Base 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).
101ERROR
102 }
10318118µs $sigdie = $SIG{__DIE__} || undef;
104 }
105 # Make sure a global $SIG{__DIE__} makes it out of the localization.
1061811µs $SIG{__DIE__} = $sigdie if defined $sigdie;
107 ${$base.'::VERSION'} = "-1, set by base.pm"
10818109µs unless defined ${$base.'::VERSION'};
109 }
1105773µs push @bases, $base;
111
11257390µs114805µ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.
12356266µs push @{"$inheritor\::ISA"}, @isa_classes;
124
12556534µs push @{"$inheritor\::ISA"}, @bases;
126
12756401µs if( defined $fields_base ) {
128 inherit_fields($inheritor, $fields_base);
129 }
130}
131
132sub 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!
147This will cause problems. Be sure you use base BEFORE declaring fields.
148END
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
17816µs1;
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
sub base::CORE:match; # opcode