Filename | /usr/lib/perl/5.10/Scalar/Util.pm |
Statements | Executed 14 statements in 625µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
41 | 5 | 2 | 193µs | 193µs | blessed (xsub) | Scalar::Util::
1 | 1 | 1 | 28µs | 34µs | BEGIN@9 | Scalar::Util::
1 | 1 | 1 | 26µs | 26µs | weaken (xsub) | Scalar::Util::
1 | 1 | 1 | 12µs | 88µs | BEGIN@10 | Scalar::Util::
0 | 0 | 0 | 0s | 0s | export_fail | Scalar::Util::
0 | 0 | 0 | 0s | 0s | openhandle | Scalar::Util::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # Scalar::Util.pm | ||||
2 | # | ||||
3 | # Copyright (c) 1997-2007 Graham Barr <gbarr@pobox.com>. All rights reserved. | ||||
4 | # This program is free software; you can redistribute it and/or | ||||
5 | # modify it under the same terms as Perl itself. | ||||
6 | |||||
7 | package Scalar::Util; | ||||
8 | |||||
9 | 3 | 34µs | 2 | 40µs | # spent 34µs (28+6) within Scalar::Util::BEGIN@9 which was called:
# once (28µs+6µs) by Compress::Zlib::BEGIN@9 at line 9 # spent 34µs making 1 call to Scalar::Util::BEGIN@9
# spent 6µs making 1 call to strict::import |
10 | 3 | 437µs | 2 | 164µs | # spent 88µs (12+76) within Scalar::Util::BEGIN@10 which was called:
# once (12µs+76µs) by Compress::Zlib::BEGIN@9 at line 10 # spent 88µs making 1 call to Scalar::Util::BEGIN@10
# spent 76µs making 1 call to vars::import |
11 | 1 | 1µs | require Exporter; | ||
12 | 1 | 94µs | require List::Util; # List::Util loads the XS | ||
13 | |||||
14 | 1 | 12µs | @ISA = qw(Exporter); | ||
15 | 1 | 2µs | @EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring looks_like_number set_prototype); | ||
16 | 1 | 300ns | $VERSION = "1.21"; | ||
17 | 1 | 31µs | $VERSION = eval $VERSION; # spent 6µs executing statements in string eval | ||
18 | |||||
19 | 1 | 1µs | unless (defined &dualvar) { | ||
20 | # Load Pure Perl version if XS not loaded | ||||
21 | require Scalar::Util::PP; | ||||
22 | Scalar::Util::PP->import; | ||||
23 | push @EXPORT_FAIL, qw(weaken isweak dualvar isvstring set_prototype); | ||||
24 | } | ||||
25 | |||||
26 | sub export_fail { | ||||
27 | if (grep { /dualvar/ } @EXPORT_FAIL) { # no XS loaded | ||||
28 | my $pat = join("|", @EXPORT_FAIL); | ||||
29 | if (my ($err) = grep { /^($pat)$/ } @_ ) { | ||||
30 | require Carp; | ||||
31 | Carp::croak("$err is only available with the XS version of Scalar::Util"); | ||||
32 | } | ||||
33 | } | ||||
34 | |||||
35 | if (grep { /^(weaken|isweak)$/ } @_ ) { | ||||
36 | require Carp; | ||||
37 | Carp::croak("Weak references are not implemented in the version of perl"); | ||||
38 | } | ||||
39 | |||||
40 | if (grep { /^(isvstring)$/ } @_ ) { | ||||
41 | require Carp; | ||||
42 | Carp::croak("Vstrings are not implemented in the version of perl"); | ||||
43 | } | ||||
44 | |||||
45 | @_; | ||||
46 | } | ||||
47 | |||||
48 | sub openhandle ($) { | ||||
49 | my $fh = shift; | ||||
50 | my $rt = reftype($fh) || ''; | ||||
51 | |||||
52 | return defined(fileno($fh)) ? $fh : undef | ||||
53 | if $rt eq 'IO'; | ||||
54 | |||||
55 | if (reftype(\$fh) eq 'GLOB') { # handle openhandle(*DATA) | ||||
56 | $fh = \(my $tmp=$fh); | ||||
57 | } | ||||
58 | elsif ($rt ne 'GLOB') { | ||||
59 | return undef; | ||||
60 | } | ||||
61 | |||||
62 | (tied(*$fh) or defined(fileno($fh))) | ||||
63 | ? $fh : undef; | ||||
64 | } | ||||
65 | |||||
66 | 1 | 12µs | 1; | ||
67 | |||||
68 | __END__ | ||||
# spent 193µs within Scalar::Util::blessed which was called 41 times, avg 5µs/call:
# 12 times (40µs+0s) by Template::Iterator::new at line 55 of Template/Iterator.pm, avg 3µs/call
# 10 times (50µs+0s) by Template::Context::template at line 87 of Template/Context.pm, avg 5µs/call
# 9 times (66µs+0s) by Template::Context::process at line 331 of Template/Context.pm, avg 7µs/call
# 9 times (33µs+0s) by Template::Context::process at line 373 of Template/Context.pm, avg 4µs/call
# once (4µs+0s) by Template::Context::process at line 339 of Template/Context.pm | |||||
# spent 26µs within Scalar::Util::weaken which was called:
# once (26µs+0s) by C4::Context::BEGIN@101 at line 289 of DBI.pm |