← 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 11:58:52 2013
Reported on Tue Oct 15 12:02:24 2013

Filename/usr/share/perl5/YAML/Base.pm
StatementsExecuted 1017 statements in 5.46ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
212122.70ms4.25msYAML::Base::::fieldYAML::Base::field
6421764µs764µsYAML::Base::::newYAML::Base::new
2111296µs296µsYAML::Base::::__ANON__[:162]YAML::Base::__ANON__[:162]
1711276µs1.25msYAML::Base::::__ANON__[:172]YAML::Base::__ANON__[:172]
3421110µs110µsYAML::Base::::CORE:substYAML::Base::CORE:subst (opcode)
11118µs44µsYAML::Base::::BEGIN@165YAML::Base::BEGIN@165
11118µs22µsYAML::Base::::BEGIN@3YAML::Base::BEGIN@3
11113µs36µsYAML::Base::::BEGIN@75YAML::Base::BEGIN@75
11110µs22µsYAML::Base::::BEGIN@4YAML::Base::BEGIN@4
1119µs9µsYAML::Base::::BEGIN@5YAML::Base::BEGIN@5
0000s0sYAML::Base::::XXXYAML::Base::XXX
0000s0sYAML::Base::::__ANON__[:124]YAML::Base::__ANON__[:124]
0000s0sYAML::Base::::__ANON__[:133]YAML::Base::__ANON__[:133]
0000s0sYAML::Base::::__ANON__[:146]YAML::Base::__ANON__[:146]
0000s0sYAML::Base::::dieYAML::Base::die
0000s0sYAML::Base::::node_infoYAML::Base::node_info
0000s0sYAML::Base::::warnYAML::Base::warn
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package YAML::Base;
2
3327µs225µs
# spent 22µs (18+4) within YAML::Base::BEGIN@3 which was called: # once (18µs+4µs) by YAML::BEGIN@6 at line 3
use strict;
# spent 22µs making 1 call to YAML::Base::BEGIN@3 # spent 4µs making 1 call to strict::import
4334µs234µs
# spent 22µs (10+12) within YAML::Base::BEGIN@4 which was called: # once (10µs+12µs) by YAML::BEGIN@6 at line 4
use warnings;
# spent 22µs making 1 call to YAML::Base::BEGIN@4 # spent 12µs making 1 call to warnings::import
53401µs19µs
# spent 9µs within YAML::Base::BEGIN@5 which was called: # once (9µs+0s) by YAML::BEGIN@6 at line 5
use Exporter ();
# spent 9µs making 1 call to YAML::Base::BEGIN@5
6
71800nsour $VERSION = '0.71';
8112µsour @ISA = 'Exporter';
91800nsour @EXPORT = qw(field XXX);
10
11
# spent 764µs within YAML::Base::new which was called 64 times, avg 12µs/call: # 32 times (526µs+0s) by YAML::Load at line 33 of YAML.pm, avg 16µs/call # 32 times (239µs+0s) by YAML::init_action_object at line 87 of YAML.pm, avg 7µs/call
sub new {
126461µs my $class = shift;
136445µs $class = ref($class) || $class;
1464332µs my $self = bless {}, $class;
156484µs while (@_) {
16 my $method = shift;
17 $self->$method(shift);
18 }
1964322µs return $self;
20}
21
22# Use lexical subs to reduce pollution of private methods by base class.
231500nsmy ($_new_error, $_info, $_scalar_info, $parse_arguments, $default_as_code);
24
25sub XXX {
26 require Data::Dumper;
27 CORE::die(Data::Dumper::Dumper(@_));
28}
29
3016µsmy %code = (
31 sub_start =>
32 "sub {\n",
33 set_default =>
34 " \$_[0]->{%s} = %s\n unless exists \$_[0]->{%s};\n",
35 init =>
36 " return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" .
37 " unless \$#_ > 0 or defined \$_[0]->{%s};\n",
38 return_if_get =>
39 " return \$_[0]->{%s} unless \$#_ > 0;\n",
40 set =>
41 " \$_[0]->{%s} = \$_[1];\n",
42 sub_end =>
43 " return \$_[0]->{%s};\n}\n",
44);
45
46
# spent 4.25ms (2.70+1.55) within YAML::Base::field which was called 21 times, avg 202µs/call: # once (254µs+191µs) by YAML::Loader::BEGIN@6 at line 10 of YAML/Loader/Base.pm # once (150µs+196µs) by C4::Search::BEGIN@34 at line 18 of YAML.pm # once (192µs+104µs) by YAML::Loader::BEGIN@6 at line 13 of YAML/Loader/Base.pm # once (131µs+112µs) by YAML::Loader::BEGIN@6 at line 17 of YAML/Loader/Base.pm # once (125µs+91µs) by YAML::Loader::BEGIN@6 at line 16 of YAML/Loader/Base.pm # once (137µs+65µs) by C4::Search::BEGIN@34 at line 20 of YAML.pm # once (134µs+66µs) by C4::Search::BEGIN@34 at line 22 of YAML.pm # once (113µs+75µs) by C4::Search::BEGIN@34 at line 19 of YAML.pm # once (115µs+70µs) by YAML::Loader::BEGIN@6 at line 11 of YAML/Loader/Base.pm # once (121µs+64µs) by YAML::Loader::BEGIN@6 at line 22 of YAML/Loader/Base.pm # once (110µs+68µs) by YAML::Loader::BEGIN@6 at line 21 of YAML/Loader/Base.pm # once (108µs+69µs) by YAML::Loader::BEGIN@6 at line 19 of YAML/Loader/Base.pm # once (107µs+70µs) by YAML::Loader::BEGIN@6 at line 23 of YAML/Loader/Base.pm # once (109µs+66µs) by YAML::Loader::BEGIN@6 at line 25 of YAML/Loader/Base.pm # once (110µs+65µs) by YAML::Loader::BEGIN@6 at line 12 of YAML/Loader/Base.pm # once (109µs+64µs) by YAML::Loader::BEGIN@6 at line 26 of YAML/Loader/Base.pm # once (108µs+64µs) by YAML::Loader::BEGIN@6 at line 24 of YAML/Loader/Base.pm # once (149µs+13µs) by YAML::Loader::BEGIN@6 at line 20 of YAML/Loader/Base.pm # once (110µs+14µs) by YAML::Loader::BEGIN@6 at line 14 of YAML/Loader/Base.pm # once (107µs+13µs) by YAML::Loader::BEGIN@6 at line 18 of YAML/Loader/Base.pm # once (100µs+12µs) by YAML::Loader::BEGIN@6 at line 15 of YAML/Loader/Base.pm
sub field {
472118µs my $package = caller;
4821110µs21296µs my ($args, @values) = &$parse_arguments(
# spent 296µs making 21 calls to YAML::Base::__ANON__[YAML/Base.pm:162], avg 14µs/call
49 [ qw(-package -init) ],
50 @_,
51 );
522113µs my ($field, $default) = @values;
532121µs $package = $args->{-package} if defined $args->{-package};
542135µs return if defined &{"${package}::$field"};
552152µs171.25ms my $default_string =
# spent 1.25ms making 17 calls to YAML::Base::__ANON__[YAML/Base.pm:172], avg 74µs/call
56 ( ref($default) eq 'ARRAY' and not @$default )
57 ? '[]'
58 : (ref($default) eq 'HASH' and not keys %$default )
59 ? '{}'
60 : &$default_as_code($default);
61
622120µs my $code = $code{sub_start};
632122µs if ($args->{-init}) {
6422µs my $fragment = $code{init};
6528µs $code .= sprintf $fragment, $field, $args->{-init}, ($field) x 4;
66 }
672153µs $code .= sprintf $code{set_default}, $field, $default_string, $field
68 if defined $default;
692124µs $code .= sprintf $code{return_if_get}, $field;
702119µs $code .= sprintf $code{set}, $field;
712117µs $code .= sprintf $code{sub_end}, $field;
72
73211.90ms my $sub = eval $code;
# spent 1.72ms executing statements in string eval
# includes 1.34ms spent executing 288 calls to 1 sub defined therein. # spent 1.03ms executing statements in string eval
# includes 836µs spent executing 128 calls to 1 sub defined therein. # spent 867µs executing statements in string eval
# includes 743µs spent executing 96 calls to 1 sub defined therein. # spent 832µs executing statements in string eval
# includes 617µs spent executing 64 calls to 1 sub defined therein. # spent 675µs executing statements in string eval
# includes 668µs spent executing 32 calls to 1 sub defined therein. # spent 616µs executing statements in string eval
# includes 532µs spent executing 64 calls to 1 sub defined therein. # spent 563µs executing statements in string eval
# includes 473µs spent executing 64 calls to 1 sub defined therein. # spent 372µs executing statements in string eval
# includes 343µs spent executing 32 calls to 1 sub defined therein. # spent 11µs executing statements in string eval # spent 9µs executing statements in string eval # spent 9µs executing statements in string eval # spent 8µs executing statements in string eval # spent 8µs executing statements in string eval # spent 6µs executing statements in string eval # spent 6µs executing statements in string eval # spent 6µs executing statements in string eval # spent 6µs executing statements in string eval # spent 6µs executing statements in string eval # spent 6µs executing statements in string eval # spent 6µs executing statements in string eval # spent 5µs executing statements in string eval
74217µs die $@ if $@;
753708µs259µs
# spent 36µs (13+23) within YAML::Base::BEGIN@75 which was called: # once (13µs+23µs) by YAML::BEGIN@6 at line 75
no strict 'refs';
# spent 36µs making 1 call to YAML::Base::BEGIN@75 # spent 23µs making 1 call to strict::unimport
762189µs *{"${package}::$field"} = $sub;
7721147µs return $code if defined wantarray;
78}
79
80sub die {
81 my $self = shift;
82 my $error = $self->$_new_error(@_);
83 $error->type('Error');
84 Carp::croak($error->format_message);
85}
86
87sub warn {
88 my $self = shift;
89 return unless $^W;
90 my $error = $self->$_new_error(@_);
91 $error->type('Warning');
92 Carp::cluck($error->format_message);
93}
94
95# This code needs to be refactored to be simpler and more precise, and no,
96# Scalar::Util doesn't DWIM.
97#
98# Can't handle:
99# * blessed regexp
100sub node_info {
101 my $self = shift;
102 my $stringify = $_[1] || 0;
103 my ($class, $type, $id) =
104 ref($_[0])
105 ? $stringify
106 ? &$_info("$_[0]")
107 : do {
108 require overload;
109 my @info = &$_info(overload::StrVal($_[0]));
110 if (ref($_[0]) eq 'Regexp') {
111 @info[0, 1] = (undef, 'REGEXP');
112 }
113 @info;
114 }
115 : &$_scalar_info($_[0]);
116 ($class, $type, $id) = &$_scalar_info("$_[0]")
117 unless $id;
118 return wantarray ? ($class, $type, $id) : $id;
119}
120
121#-------------------------------------------------------------------------------
122$_info = sub {
123 return (($_[0]) =~ qr{^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$}o);
12412µs};
125
126$_scalar_info = sub {
127 my $id = 'undef';
128 if (defined $_[0]) {
129 \$_[0] =~ /\((\w+)\)$/o or CORE::die();
130 $id = "$1-S";
131 }
132 return (undef, undef, $id);
13312µs};
134
135$_new_error = sub {
136 require Carp;
137 my $self = shift;
138 require YAML::Error;
139
140 my $code = shift || 'unknown error';
141 my $error = YAML::Error->new(code => $code);
142 $error->line($self->line) if $self->can('line');
143 $error->document($self->document) if $self->can('document');
144 $error->arguments([@_]);
145 return $error;
14612µs};
147
148
# spent 296µs within YAML::Base::__ANON__[/usr/share/perl5/YAML/Base.pm:162] which was called 21 times, avg 14µs/call: # 21 times (296µs+0s) by YAML::Base::field at line 48, avg 14µs/call
$parse_arguments = sub {
1492115µs my $paired_arguments = shift || [];
1502124µs my ($args, @values) = ({}, ());
1512181µs my %pairs = map { ($_, 1) } @$paired_arguments;
1522114µs while (@_) {
1534217µs my $elem = shift;
1544258µs if (defined $elem and defined $pairs{$elem} and @_) {
155 $args->{$elem} = shift;
156 }
157 else {
1584023µs push @values, $elem;
159 }
160 }
1612197µs return wantarray ? ($args, @values) : $args;
16212µs};
163
164
# spent 1.25ms (276µs+979µs) within YAML::Base::__ANON__[/usr/share/perl5/YAML/Base.pm:172] which was called 17 times, avg 74µs/call: # 17 times (276µs+979µs) by YAML::Base::field at line 55, avg 74µs/call
$default_as_code = sub {
1653119µs270µs
# spent 44µs (18+26) within YAML::Base::BEGIN@165 which was called: # once (18µs+26µs) by YAML::BEGIN@6 at line 165
no warnings 'once';
# spent 44µs making 1 call to YAML::Base::BEGIN@165 # spent 26µs making 1 call to warnings::unimport
1661714µs require Data::Dumper;
1671711µs local $Data::Dumper::Sortkeys = 1;
16817118µs17869µs my $code = Data::Dumper::Dumper(shift);
# spent 869µs making 17 calls to Data::Dumper::Dumper, avg 51µs/call
16917127µs1776µs $code =~ s/^\$VAR1 = //;
# spent 76µs making 17 calls to YAML::Base::CORE:subst, avg 4µs/call
1701768µs1734µs $code =~ s/;$//;
# spent 34µs making 17 calls to YAML::Base::CORE:subst, avg 2µs/call
1711756µs return $code;
17212µs};
173
17419µs1;
175
176__END__
 
# spent 110µs within YAML::Base::CORE:subst which was called 34 times, avg 3µs/call: # 17 times (76µs+0s) by YAML::Base::__ANON__[/usr/share/perl5/YAML/Base.pm:172] at line 169, avg 4µs/call # 17 times (34µs+0s) by YAML::Base::__ANON__[/usr/share/perl5/YAML/Base.pm:172] at line 170, avg 2µs/call
sub YAML::Base::CORE:subst; # opcode