← 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:01:40 2013

Filename/usr/share/perl5/YAML/Node.pm
StatementsExecuted 20 statements in 1.51ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111269µs438µsYAML::Node::::BEGIN@7 YAML::Node::BEGIN@7
11119µs23µsYAML::Node::::BEGIN@3 YAML::Node::BEGIN@3
11116µs31µsYAML::Node::::BEGIN@4 YAML::Node::BEGIN@4
11110µs48µsYAML::Node::::BEGIN@6 YAML::Node::BEGIN@6
0000s0sYAML::Node::::keys YAML::Node::keys
0000s0sYAML::Node::::kind YAML::Node::kind
0000s0sYAML::Node::::new YAML::Node::new
0000s0sYAML::Node::::node YAML::Node::node
0000s0sYAML::Node::::tag YAML::Node::tag
0000s0sYAML::Node::::ynode YAML::Node::ynode
0000s0syaml_mapping::::CLEAR yaml_mapping::CLEAR
0000s0syaml_mapping::::DELETE yaml_mapping::DELETE
0000s0syaml_mapping::::EXISTS yaml_mapping::EXISTS
0000s0syaml_mapping::::FETCH yaml_mapping::FETCH
0000s0syaml_mapping::::FIRSTKEY yaml_mapping::FIRSTKEY
0000s0syaml_mapping::::NEXTKEY yaml_mapping::NEXTKEY
0000s0syaml_mapping::::STORE yaml_mapping::STORE
0000s0syaml_mapping::::TIEHASH yaml_mapping::TIEHASH
0000s0syaml_mapping::::new yaml_mapping::new
0000s0syaml_scalar::::FETCH yaml_scalar::FETCH
0000s0syaml_scalar::::STORE yaml_scalar::STORE
0000s0syaml_scalar::::TIESCALAR yaml_scalar::TIESCALAR
0000s0syaml_scalar::::new yaml_scalar::new
0000s0syaml_sequence::::FETCHyaml_sequence::FETCH
0000s0syaml_sequence::::FETCHSIZEyaml_sequence::FETCHSIZE
0000s0syaml_sequence::::STOREyaml_sequence::STORE
0000s0syaml_sequence::::TIEARRAYyaml_sequence::TIEARRAY
0000s0syaml_sequence::::newyaml_sequence::new
0000s0syaml_sequence::::undoneyaml_sequence::undone
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package YAML::Node;
2
3328µs228µs
# spent 23µs (19+5) within YAML::Node::BEGIN@3 which was called: # once (19µs+5µs) by YAML::BEGIN@7 at line 3
use strict;
# spent 23µs making 1 call to YAML::Node::BEGIN@3 # spent 5µs making 1 call to strict::import
4328µs245µs
# spent 31µs (16+14) within YAML::Node::BEGIN@4 which was called: # once (16µs+14µs) by YAML::BEGIN@7 at line 4
use warnings;
# spent 31µs making 1 call to YAML::Node::BEGIN@4 # spent 14µs making 1 call to warnings::import
5
6328µs287µs
# spent 48µs (10+39) within YAML::Node::BEGIN@6 which was called: # once (10µs+39µs) by YAML::BEGIN@7 at line 6
use YAML::Base;
# spent 48µs making 1 call to YAML::Node::BEGIN@6 # spent 39µs making 1 call to Exporter::import
731.38ms1438µs
# spent 438µs (269+169) within YAML::Node::BEGIN@7 which was called: # once (269µs+169µs) by YAML::BEGIN@7 at line 7
use YAML::Tag;
# spent 438µs making 1 call to YAML::Node::BEGIN@7
8
91800nsour $VERSION = '0.71';
10113µsour @ISA = 'YAML::Base';
111800nsour @EXPORT = qw(ynode);
12
13sub ynode {
14 my $self;
15 if (ref($_[0]) eq 'HASH') {
16 $self = tied(%{$_[0]});
17 }
18 elsif (ref($_[0]) eq 'ARRAY') {
19 $self = tied(@{$_[0]});
20 }
21 else {
22 $self = tied($_[0]);
23 }
24 return (ref($self) =~ /^yaml_/) ? $self : undef;
25}
26
27sub new {
28 my ($class, $node, $tag) = @_;
29 my $self;
30 $self->{NODE} = $node;
31 my (undef, $type) = $class->node_info($node);
32 $self->{KIND} = (not defined $type) ? 'scalar' :
33 ($type eq 'ARRAY') ? 'sequence' :
34 ($type eq 'HASH') ? 'mapping' :
35 $class->die("Can't create YAML::Node from '$type'");
36 tag($self, ($tag || ''));
37 if ($self->{KIND} eq 'scalar') {
38 yaml_scalar->new($self, $_[1]);
39 return \ $_[1];
40 }
41 my $package = "yaml_" . $self->{KIND};
42 $package->new($self)
43}
44
45sub node { $_->{NODE} }
46sub kind { $_->{KIND} }
47sub tag {
48 my ($self, $value) = @_;
49 if (defined $value) {
50 $self->{TAG} = YAML::Tag->new($value);
51 return $self;
52 }
53 else {
54 return $self->{TAG};
55 }
56}
57sub keys {
58 my ($self, $value) = @_;
59 if (defined $value) {
60 $self->{KEYS} = $value;
61 return $self;
62 }
63 else {
64 return $self->{KEYS};
65 }
66}
67
68#==============================================================================
69package yaml_scalar;
70
7116µs@yaml_scalar::ISA = qw(YAML::Node);
72
73sub new {
74 my ($class, $self) = @_;
75 tie $_[2], $class, $self;
76}
77
78sub TIESCALAR {
79 my ($class, $self) = @_;
80 bless $self, $class;
81 $self
82}
83
84sub FETCH {
85 my ($self) = @_;
86 $self->{NODE}
87}
88
89sub STORE {
90 my ($self, $value) = @_;
91 $self->{NODE} = $value
92}
93
94#==============================================================================
95package yaml_sequence;
96
9715µs@yaml_sequence::ISA = qw(YAML::Node);
98
99sub new {
100 my ($class, $self) = @_;
101 my $new;
102 tie @$new, $class, $self;
103 $new
104}
105
106sub TIEARRAY {
107 my ($class, $self) = @_;
108 bless $self, $class
109}
110
111sub FETCHSIZE {
112 my ($self) = @_;
113 scalar @{$self->{NODE}};
114}
115
116sub FETCH {
117 my ($self, $index) = @_;
118 $self->{NODE}[$index]
119}
120
121sub STORE {
122 my ($self, $index, $value) = @_;
123 $self->{NODE}[$index] = $value
124}
125
126sub undone {
127 die "Not implemented yet"; # XXX
128}
129
13014µs*STORESIZE = *POP = *PUSH = *SHIFT = *UNSHIFT = *SPLICE = *DELETE = *EXISTS =
131*STORESIZE = *POP = *PUSH = *SHIFT = *UNSHIFT = *SPLICE = *DELETE = *EXISTS =
132*undone; # XXX Must implement before release
133
134#==============================================================================
135package yaml_mapping;
136
13715µs@yaml_mapping::ISA = qw(YAML::Node);
138
139sub new {
140 my ($class, $self) = @_;
141 @{$self->{KEYS}} = sort keys %{$self->{NODE}};
142 my $new;
143 tie %$new, $class, $self;
144 $new
145}
146
147sub TIEHASH {
148 my ($class, $self) = @_;
149 bless $self, $class
150}
151
152sub FETCH {
153 my ($self, $key) = @_;
154 if (exists $self->{NODE}{$key}) {
155 return (grep {$_ eq $key} @{$self->{KEYS}})
156 ? $self->{NODE}{$key} : undef;
157 }
158 return $self->{HASH}{$key};
159}
160
161sub STORE {
162 my ($self, $key, $value) = @_;
163 if (exists $self->{NODE}{$key}) {
164 $self->{NODE}{$key} = $value;
165 }
166 elsif (exists $self->{HASH}{$key}) {
167 $self->{HASH}{$key} = $value;
168 }
169 else {
170 if (not grep {$_ eq $key} @{$self->{KEYS}}) {
171 push(@{$self->{KEYS}}, $key);
172 }
173 $self->{HASH}{$key} = $value;
174 }
175 $value
176}
177
178sub DELETE {
179 my ($self, $key) = @_;
180 my $return;
181 if (exists $self->{NODE}{$key}) {
182 $return = $self->{NODE}{$key};
183 }
184 elsif (exists $self->{HASH}{$key}) {
185 $return = delete $self->{NODE}{$key};
186 }
187 for (my $i = 0; $i < @{$self->{KEYS}}; $i++) {
188 if ($self->{KEYS}[$i] eq $key) {
189 splice(@{$self->{KEYS}}, $i, 1);
190 }
191 }
192 return $return;
193}
194
195sub CLEAR {
196 my ($self) = @_;
197 @{$self->{KEYS}} = ();
198 %{$self->{HASH}} = ();
199}
200
201sub FIRSTKEY {
202 my ($self) = @_;
203 $self->{ITER} = 0;
204 $self->{KEYS}[0]
205}
206
207sub NEXTKEY {
208 my ($self) = @_;
209 $self->{KEYS}[++$self->{ITER}]
210}
211
212sub EXISTS {
213 my ($self, $key) = @_;
214 exists $self->{NODE}{$key}
215}
216
21719µs1;
218
219__END__