← Index
NYTProf Performance Profile   « line view »
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 14:31:06 2016
Reported on Fri Jan 8 14:33:27 2016

Filename/usr/share/perl5/JSON.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11115.2ms20.6msJSON::::_load_xs JSON::_load_xs
111690µs690µsJSON::::CORE:readline JSON::CORE:readline (opcode)
444546µs705µsJSON::::import JSON::import
221422µs540µsJSON::Boolean::::_overrride_overload JSON::Boolean::_overrride_overload
11168µs68µsJSON::::_set_module JSON::_set_module
11159µs79µsJSON::::to_json JSON::to_json
11159µs59µsJSON::::CORE:close JSON::CORE:close (opcode)
11127µs46µsJSON::::BEGIN@318 JSON::BEGIN@318
11127µs45µsJSON::Backend::PP::::BEGIN@398JSON::Backend::PP::BEGIN@398
11120µs36µsJSON::::BEGIN@4 JSON::BEGIN@4
11118µs183µsJSON::::BEGIN@6 JSON::BEGIN@6
1118µs8µsJSON::::BEGIN@9 JSON::BEGIN@9
1115µs5µsJSON::::BEGIN@5 JSON::BEGIN@5
0000s0sJSON::Backend::PP::::__ANON__[:401]JSON::Backend::PP::__ANON__[:401]
0000s0sJSON::Backend::PP::::__ANON__[:402]JSON::Backend::PP::__ANON__[:402]
0000s0sJSON::Backend::PP::::initJSON::Backend::PP::init
0000s0sJSON::Boolean::::__ANON__[:375] JSON::Boolean::__ANON__[:375]
0000s0sJSON::Boolean::::__ANON__[:376] JSON::Boolean::__ANON__[:376]
0000s0sJSON::Boolean::::__ANON__[:382] JSON::Boolean::__ANON__[:382]
0000s0sJSON::Boolean::::__ANON__[:383] JSON::Boolean::__ANON__[:383]
0000s0sJSON::::__ANON__[:332] JSON::__ANON__[:332]
0000s0sJSON::::_load_pp JSON::_load_pp
0000s0sJSON::::backend JSON::backend
0000s0sJSON::::false JSON::false
0000s0sJSON::::from_json JSON::from_json
0000s0sJSON::::is_pp JSON::is_pp
0000s0sJSON::::is_xs JSON::is_xs
0000s0sJSON::::jsonToObj JSON::jsonToObj
0000s0sJSON::::null JSON::null
0000s0sJSON::::objToJson JSON::objToJson
0000s0sJSON::::property JSON::property
0000s0sJSON::::pureperl_only_methods JSON::pureperl_only_methods
0000s0sJSON::::require_xs_version JSON::require_xs_version
0000s0sJSON::::true JSON::true
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package JSON;
2
3
4252µs
# spent 36µs (20+16) within JSON::BEGIN@4 which was called: # once (20µs+16µs) by C4::Auth::BEGIN@23 at line 4
use strict;
# spent 36µs making 1 call to JSON::BEGIN@4 # spent 16µs making 1 call to strict::import
515µs
# spent 5µs within JSON::BEGIN@5 which was called: # once (5µs+0s) by C4::Auth::BEGIN@23 at line 5
use Carp ();
# spent 5µs making 1 call to JSON::BEGIN@5
62348µs
# spent 183µs (18+165) within JSON::BEGIN@6 which was called: # once (18µs+165µs) by C4::Auth::BEGIN@23 at line 6
use base qw(Exporter);
# spent 183µs making 1 call to JSON::BEGIN@6 # spent 165µs making 1 call to base::import
7@JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_json);
8
9
# spent 8µs within JSON::BEGIN@9 which was called: # once (8µs+0s) by C4::Auth::BEGIN@23 at line 13
BEGIN {
10 $JSON::VERSION = '2.61';
11 $JSON::DEBUG = 0 unless (defined $JSON::DEBUG);
12 $JSON::DEBUG = $ENV{ PERL_JSON_DEBUG } if exists $ENV{ PERL_JSON_DEBUG };
1318µs}
# spent 8µs making 1 call to JSON::BEGIN@9
14
15my $Module_XS = 'JSON::XS';
16my $Module_PP = 'JSON::PP';
17my $Module_bp = 'JSON::backportPP'; # included in JSON distribution
18my $PP_Version = '2.27203';
19my $XS_Version = '2.34';
20
21
22# XS and PP common methods
23
24my @PublicMethods = qw/
25 ascii latin1 utf8 pretty indent space_before space_after relaxed canonical allow_nonref
26 allow_blessed convert_blessed filter_json_object filter_json_single_key_object
27 shrink max_depth max_size encode decode decode_prefix allow_unknown
28/;
29
30my @Properties = qw/
31 ascii latin1 utf8 indent space_before space_after relaxed canonical allow_nonref
32 allow_blessed convert_blessed shrink max_depth max_size allow_unknown
33/;
34
35my @XSOnlyMethods = qw//; # Currently nothing
36
37my @PPOnlyMethods = qw/
38 indent_length sort_by
39 allow_singlequote allow_bignum loose allow_barekey escape_slash as_nonblessed
40/; # JSON::PP specific
41
42
43# used in _load_xs and _load_pp ($INSTALL_ONLY is not used currently)
44my $_INSTALL_DONT_DIE = 1; # When _load_xs fails to load XS, don't die.
45my $_INSTALL_ONLY = 2; # Don't call _set_methods()
46my $_ALLOW_UNSUPPORTED = 0;
47my $_UNIV_CONV_BLESSED = 0;
48my $_USSING_bpPP = 0;
49
50
51# Check the environment variable to decide worker module.
52
53unless ($JSON::Backend) {
54 $JSON::DEBUG and Carp::carp("Check used worker module...");
55
56 my $backend = exists $ENV{PERL_JSON_BACKEND} ? $ENV{PERL_JSON_BACKEND} : 1;
57
58120.6ms if ($backend eq '1' or $backend =~ /JSON::XS\s*,\s*JSON::PP/) {
# spent 20.6ms making 1 call to JSON::_load_xs
59 _load_xs($_INSTALL_DONT_DIE) or _load_pp();
60 }
61 elsif ($backend eq '0' or $backend eq 'JSON::PP') {
62 _load_pp();
63 }
64 elsif ($backend eq '2' or $backend eq 'JSON::XS') {
65 _load_xs();
66 }
67 elsif ($backend eq 'JSON::backportPP') {
68 $_USSING_bpPP = 1;
69 _load_pp();
70 }
71 else {
72 Carp::croak "The value of environmental variable 'PERL_JSON_BACKEND' is invalid.";
73 }
74}
75
76
77
# spent 705µs (546+158) within JSON::import which was called 4 times, avg 176µs/call: # once (272µs+87µs) by CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@34 at line 34 of circ/ysearch.pl # once (134µs+33µs) by C4::Auth::BEGIN@23 at line 23 of C4/Auth.pm # once (71µs+20µs) by Koha::Template::Plugin::AudioAlerts::BEGIN@23 at line 23 of Koha/Template/Plugin/AudioAlerts.pm # once (70µs+19µs) by C4::Search::History::BEGIN@9 at line 9 of C4/Search/History.pm
sub import {
78 my $pkg = shift;
79 my @what_to_export;
80 my $no_export;
81
82 for my $tag (@_) {
83 if ($tag eq '-support_by_pp') {
84 if (!$_ALLOW_UNSUPPORTED++) {
85 JSON::Backend::XS
86 ->support_by_pp(@PPOnlyMethods) if ($JSON::Backend eq $Module_XS);
87 }
88 next;
89 }
90 elsif ($tag eq '-no_export') {
91 $no_export++, next;
92 }
93 elsif ( $tag eq '-convert_blessed_universally' ) {
94 eval q|
95 require B;
96 *UNIVERSAL::TO_JSON = sub {
97 my $b_obj = B::svref_2object( $_[0] );
98 return $b_obj->isa('B::HV') ? { %{ $_[0] } }
99 : $b_obj->isa('B::AV') ? [ @{ $_[0] } ]
100 : undef
101 ;
102 }
103 | if ( !$_UNIV_CONV_BLESSED++ );
104 next;
105 }
106 push @what_to_export, $tag;
107 }
108
109 return if ($no_export);
110
1114158µs __PACKAGE__->export_to_level(1, $pkg, @what_to_export);
# spent 158µs making 4 calls to Exporter::export_to_level, avg 40µs/call
112}
113
114
115# OBSOLETED
116
117sub jsonToObj {
118 my $alternative = 'from_json';
119 if (defined $_[0] and UNIVERSAL::isa($_[0], 'JSON')) {
120 shift @_; $alternative = 'decode';
121 }
122 Carp::carp "'jsonToObj' will be obsoleted. Please use '$alternative' instead.";
123 return JSON::from_json(@_);
124};
125
126sub objToJson {
127 my $alternative = 'to_json';
128 if (defined $_[0] and UNIVERSAL::isa($_[0], 'JSON')) {
129 shift @_; $alternative = 'encode';
130 }
131 Carp::carp "'objToJson' will be obsoleted. Please use '$alternative' instead.";
132 JSON::to_json(@_);
133};
134
135
136# INTERFACES
137
138
# spent 79µs (59+19) within JSON::to_json which was called: # once (59µs+19µs) by CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::__ANON__[/home/vagrant/kohaclone/circ/ysearch.pl:115] at line 95 of circ/ysearch.pl
sub to_json ($@) {
139 if (
140 ref($_[0]) eq 'JSON'
141 or (@_ > 2 and $_[0] eq 'JSON')
142 ) {
143 Carp::croak "to_json should not be called as a method.";
144 }
145113µs my $json = JSON->new;
# spent 13µs making 1 call to JSON::XS::new
146
147 if (@_ == 2 and ref $_[1] eq 'HASH') {
148 my $opt = $_[1];
149 for my $method (keys %$opt) {
150 $json->$method( $opt->{$method} );
151 }
152 }
153
15415µs $json->encode($_[0]);
# spent 5µs making 1 call to JSON::XS::encode
155}
156
157
158sub from_json ($@) {
159 if ( ref($_[0]) eq 'JSON' or $_[0] eq 'JSON' ) {
160 Carp::croak "from_json should not be called as a method.";
161 }
162 my $json = JSON->new;
163
164 if (@_ == 2 and ref $_[1] eq 'HASH') {
165 my $opt = $_[1];
166 for my $method (keys %$opt) {
167 $json->$method( $opt->{$method} );
168 }
169 }
170
171 return $json->decode( $_[0] );
172}
173
174
175sub true { $JSON::true }
176
177sub false { $JSON::false }
178
179sub null { undef; }
180
181
182sub require_xs_version { $XS_Version; }
183
184sub backend {
185 my $proto = shift;
186 $JSON::Backend;
187}
188
189#*module = *backend;
190
191
192sub is_xs {
193 return $_[0]->backend eq $Module_XS;
194}
195
196
197sub is_pp {
198 return not $_[0]->is_xs;
199}
200
201
202sub pureperl_only_methods { @PPOnlyMethods; }
203
204
205sub property {
206 my ($self, $name, $value) = @_;
207
208 if (@_ == 1) {
209 my %props;
210 for $name (@Properties) {
211 my $method = 'get_' . $name;
212 if ($name eq 'max_size') {
213 my $value = $self->$method();
214 $props{$name} = $value == 1 ? 0 : $value;
215 next;
216 }
217 $props{$name} = $self->$method();
218 }
219 return \%props;
220 }
221 elsif (@_ > 3) {
222 Carp::croak('property() can take only the option within 2 arguments.');
223 }
224 elsif (@_ == 2) {
225 if ( my $method = $self->can('get_' . $name) ) {
226 if ($name eq 'max_size') {
227 my $value = $self->$method();
228 return $value == 1 ? 0 : $value;
229 }
230 $self->$method();
231 }
232 }
233 else {
234 $self->$name($value);
235 }
236
237}
238
- -
241# INTERNAL
242
243
# spent 20.6ms (15.2+5.44) within JSON::_load_xs which was called: # once (15.2ms+5.44ms) by C4::Auth::BEGIN@23 at line 58
sub _load_xs {
244 my $opt = shift;
245
246 $JSON::DEBUG and Carp::carp "Load $Module_XS.";
247
248 # if called after install module, overload is disable.... why?
2491334µs JSON::Boolean::_overrride_overload($Module_XS);
# spent 334µs making 1 call to JSON::Boolean::_overrride_overload
2501206µs JSON::Boolean::_overrride_overload($Module_PP);
# spent 206µs making 1 call to JSON::Boolean::_overrride_overload
251
252 eval qq|
# spent 0s executing statements in string eval
# includes 1.66ms spent executing 1 call to 1 sub defined therein.
253 use $Module_XS $XS_Version ();
254 |;
255
256 if ($@) {
257 if (defined $opt and $opt & $_INSTALL_DONT_DIE) {
258 $JSON::DEBUG and Carp::carp "Can't load $Module_XS...($@)";
259 return 0;
260 }
261 Carp::croak $@;
262 }
263
264 unless (defined $opt and $opt & $_INSTALL_ONLY) {
265168µs _set_module( $JSON::Backend = $Module_XS );
# spent 68µs making 1 call to JSON::_set_module
2661690µs my $data = join("", <DATA>); # this code is from Jcode 2.xx.
# spent 690µs making 1 call to JSON::CORE:readline
267159µs close(DATA);
# spent 59µs making 1 call to JSON::CORE:close
268 eval $data;
# spent 0s executing statements in string eval
# includes 134µs spent executing 7 calls to 21 subs defined therein.
269145µs JSON::Backend::XS->init;
# spent 45µs making 1 call to JSON::Backend::XS::init
270 }
271
272 return 1;
273};
274
275
276sub _load_pp {
277 my $opt = shift;
278 my $backend = $_USSING_bpPP ? $Module_bp : $Module_PP;
279
280 $JSON::DEBUG and Carp::carp "Load $backend.";
281
282 # if called after install module, overload is disable.... why?
283 JSON::Boolean::_overrride_overload($Module_XS);
284 JSON::Boolean::_overrride_overload($backend);
285
286 if ( $_USSING_bpPP ) {
287 eval qq| require $backend |;
288 }
289 else {
290 eval qq| use $backend $PP_Version () |;
291 }
292
293 if ($@) {
294 if ( $backend eq $Module_PP ) {
295 $JSON::DEBUG and Carp::carp "Can't load $Module_PP ($@), so try to load $Module_bp";
296 $_USSING_bpPP++;
297 $backend = $Module_bp;
298 JSON::Boolean::_overrride_overload($backend);
299 local $^W; # if PP installed but invalid version, backportPP redefines methods.
300 eval qq| require $Module_bp |;
301 }
302 Carp::croak $@ if $@;
303 }
304
305 unless (defined $opt and $opt & $_INSTALL_ONLY) {
306 _set_module( $JSON::Backend = $Module_PP ); # even if backportPP, set $Backend with 'JSON::PP'
307 JSON::Backend::PP->init;
308 }
309};
310
311
312
# spent 68µs within JSON::_set_module which was called: # once (68µs+0s) by JSON::_load_xs at line 265
sub _set_module {
313 return if defined $JSON::true;
314
315 my $module = shift;
316
317 local $^W;
318265µs
# spent 46µs (27+19) within JSON::BEGIN@318 which was called: # once (27µs+19µs) by C4::Auth::BEGIN@23 at line 318
no strict qw(refs);
# spent 46µs making 1 call to JSON::BEGIN@318 # spent 19µs making 1 call to strict::unimport
319
320 $JSON::true = ${"$module\::true"};
321 $JSON::false = ${"$module\::false"};
322
323 push @JSON::ISA, $module;
324 push @{"$module\::Boolean::ISA"}, qw(JSON::Boolean);
325
326 *{"JSON::is_bool"} = \&{"$module\::is_bool"};
327
328 for my $method ($module eq $Module_XS ? @PPOnlyMethods : @XSOnlyMethods) {
329 *{"JSON::$method"} = sub {
330 Carp::carp("$method is not supported in $module.");
331 $_[0];
332 };
333 }
334
335 return 1;
336}
337
- -
340#
341# JSON Boolean
342#
343
344package JSON::Boolean;
345
346my %Installed;
347
348
# spent 540µs (422+118) within JSON::Boolean::_overrride_overload which was called 2 times, avg 270µs/call: # once (249µs+85µs) by JSON::_load_xs at line 249 # once (173µs+33µs) by JSON::_load_xs at line 250
sub _overrride_overload {
349 return if ($Installed{ $_[0] }++);
350
351 my $boolean = $_[0] . '::Boolean';
352
353 eval sprintf(q|
# spent 0s executing statements in string eval
# includes 35µs spent executing 1 call to 3 subs defined therein. # spent 0s executing statements in string eval
# includes 15µs spent executing 1 call to 3 subs defined therein.
354 package %s;
355 use overload (
356 '""' => sub { ${$_[0]} == 1 ? 'true' : 'false' },
357 'eq' => sub {
358 my ($obj, $op) = ref ($_[0]) ? ($_[0], $_[1]) : ($_[1], $_[0]);
359 if ($op eq 'true' or $op eq 'false') {
360 return "$obj" eq 'true' ? 'true' eq $op : 'false' eq $op;
361 }
362 else {
363 return $obj ? 1 == $op : 0 == $op;
364 }
365 },
366 );
367 |, $boolean);
368
369 if ($@) { Carp::croak $@; }
370
371 if ( exists $INC{'JSON/XS.pm'} and $boolean eq 'JSON::XS::Boolean' ) {
372 local $^W;
373 my $true = do { bless \(my $dummy = 1), $boolean };
374 my $false = do { bless \(my $dummy = 0), $boolean };
375 *JSON::XS::true = sub () { $true };
376 *JSON::XS::false = sub () { $false };
377 }
378 elsif ( exists $INC{'JSON/PP.pm'} and $boolean eq 'JSON::PP::Boolean' ) {
379 local $^W;
380 my $true = do { bless \(my $dummy = 1), $boolean };
381 my $false = do { bless \(my $dummy = 0), $boolean };
382 *JSON::PP::true = sub { $true };
383 *JSON::PP::false = sub { $false };
384 }
385
386 return 1;
387}
388
389
390#
391# Helper classes for Backend Module (PP)
392#
393
394package JSON::Backend::PP;
395
396sub init {
397 local $^W;
398262µs
# spent 45µs (27+18) within JSON::Backend::PP::BEGIN@398 which was called: # once (27µs+18µs) by C4::Auth::BEGIN@23 at line 398
no strict qw(refs); # this routine may be called after JSON::Backend::XS init was called.
# spent 45µs making 1 call to JSON::Backend::PP::BEGIN@398 # spent 18µs making 1 call to strict::unimport
399 *{"JSON::decode_json"} = \&{"JSON::PP::decode_json"};
400 *{"JSON::encode_json"} = \&{"JSON::PP::encode_json"};
401 *{"JSON::PP::is_xs"} = sub { 0 };
402 *{"JSON::PP::is_pp"} = sub { 1 };
403 return 1;
404}
405
406#
407# To save memory, the below lines are read only when XS backend is used.
408#
409
410package JSON;
411
4121;
413__DATA__
 
# spent 59µs within JSON::CORE:close which was called: # once (59µs+0s) by JSON::_load_xs at line 267
sub JSON::CORE:close; # opcode
# spent 690µs within JSON::CORE:readline which was called: # once (690µs+0s) by JSON::_load_xs at line 266
sub JSON::CORE:readline; # opcode