← 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:11:27 2013

Filename/usr/share/perl5/YAML/Node.pm
StatementsExecuted 20 statements in 1.61ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111274µs418µsYAML::Node::::BEGIN@7 YAML::Node::BEGIN@7
11118µs22µsYAML::Node::::BEGIN@3 YAML::Node::BEGIN@3
11111µs24µsYAML::Node::::BEGIN@4 YAML::Node::BEGIN@4
11110µs46µ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
3327µs226µs
# spent 22µs (18+4) within YAML::Node::BEGIN@3 which was called: # once (18µs+4µs) by YAML::BEGIN@7 at line 3
use strict;
# spent 22µs making 1 call to YAML::Node::BEGIN@3 # spent 4µs making 1 call to strict::import
4327µs236µs
# spent 24µs (11+12) within YAML::Node::BEGIN@4 which was called: # once (11µs+12µs) by YAML::BEGIN@7 at line 4
use warnings;
# spent 24µs making 1 call to YAML::Node::BEGIN@4 # spent 13µs making 1 call to warnings::import
5
6326µs282µs
# spent 46µs (10+36) within YAML::Node::BEGIN@6 which was called: # once (10µs+36µs) by YAML::BEGIN@7 at line 6
use YAML::Base;
# spent 46µs making 1 call to YAML::Node::BEGIN@6 # spent 36µs making 1 call to Exporter::import
731.48ms2422µs
# spent 418µs (274+144) within YAML::Node::BEGIN@7 which was called: # once (274µs+144µs) by YAML::BEGIN@7 at line 7
use YAML::Tag;
# spent 418µs making 1 call to YAML::Node::BEGIN@7 # spent 4µs making 1 call to UNIVERSAL::import
8
91800nsour $VERSION = '0.71';
10117µsour @ISA = 'YAML::Base';
111900nsour @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
7117µ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
9716µ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
13716µ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__