| Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/5.13.5/x86_64-linux/Scalar/Util.pm |
| Statements | Executed 12 statements in 497µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 628 | 4 | 2 | 986µs | 986µs | Scalar::Util::reftype (xsub) |
| 41 | 4 | 4 | 83µs | 83µs | Scalar::Util::weaken (xsub) |
| 43 | 4 | 4 | 68µs | 68µs | Scalar::Util::blessed (xsub) |
| 1 | 1 | 1 | 25µs | 30µs | Scalar::Util::BEGIN@9 |
| 1 | 1 | 1 | 10µs | 111µs | Scalar::Util::BEGIN@10 |
| 2 | 1 | 1 | 10µs | 10µs | Scalar::Util::refaddr (xsub) |
| 0 | 0 | 0 | 0s | 0s | Scalar::Util::export_fail |
| 0 | 0 | 0 | 0s | 0s | Scalar::Util::openhandle |
| 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 | 2 | 31µs | 2 | 36µs | # spent 30µs (25+5) within Scalar::Util::BEGIN@9 which was called:
# once (25µs+5µs) by Tie::RefHash::BEGIN@96 at line 9 # spent 30µs making 1 call to Scalar::Util::BEGIN@9
# spent 5µs making 1 call to strict::import |
| 10 | 2 | 297µs | 2 | 212µs | # spent 111µs (10+101) within Scalar::Util::BEGIN@10 which was called:
# once (10µs+101µs) by Tie::RefHash::BEGIN@96 at line 10 # spent 111µs making 1 call to Scalar::Util::BEGIN@10
# spent 101µs making 1 call to vars::import |
| 11 | 1 | 1µs | require Exporter; | ||
| 12 | 1 | 126µs | require List::Util; # List::Util loads the XS | ||
| 13 | |||||
| 14 | 1 | 7µs | @ISA = qw(Exporter); | ||
| 15 | 1 | 4µs | @EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring looks_like_number set_prototype); | ||
| 16 | 1 | 1µs | $VERSION = "1.23"; | ||
| 17 | 1 | 21µs | $VERSION = eval $VERSION; # spent 2µ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 | 9µs | 1; | ||
| 67 | |||||
| 68 | __END__ | ||||
# spent 68µs within Scalar::Util::blessed which was called 43 times, avg 2µs/call:
# 36 times (54µs+0s) by Mouse::Meta::Class::add_attribute at line 205 of Mouse/Meta/Class.pm, avg 1µs/call
# 3 times (6µs+0s) by Mouse::Util::TypeConstraints::__ANON__[/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Util/TypeConstraints.pm:217] at line 215 of Mouse/Util/TypeConstraints.pm, avg 2µs/call
# 3 times (5µs+0s) by Mouse::Util::apply_all_roles at line 276 of Mouse/Util.pm, avg 2µs/call
# once (3µs+0s) by Hailo::DEMOLISH at line 340 of Hailo.pm | |||||
# spent 10µs within Scalar::Util::refaddr which was called 2 times, avg 5µs/call:
# 2 times (10µs+0s) by Tie::RefHash::STORE at line 211 of Tie/RefHash.pm, avg 5µs/call | |||||
# spent 986µs within Scalar::Util::reftype which was called 628 times, avg 2µs/call:
# 515 times (811µs+0s) by Package::Stash::has_package_symbol at line 134 of Package/Stash.pm, avg 2µs/call
# 103 times (152µs+0s) by Package::Stash::_valid_for_type at line 74 of Package/Stash.pm, avg 1µs/call
# 7 times (16µs+0s) by Package::Stash::_valid_for_type at line 69 of Package/Stash.pm, avg 2µs/call
# 3 times (7µs+0s) by Sub::Install::_CODELIKE at line 98 of Sub/Install.pm, avg 2µs/call | |||||
# spent 83µs within Scalar::Util::weaken which was called 41 times, avg 2µs/call:
# 36 times (69µs+0s) by Mouse::Meta::Class::add_attribute at line 236 of Mouse/Meta/Class.pm, avg 2µs/call
# 3 times (7µs+0s) by Mouse::Meta::Module::create at line 231 of Mouse/Meta/Module.pm, avg 2µs/call
# once (4µs+0s) by Hailo::Storage::BEGIN@12 at line 292 of DBI.pm
# once (3µs+0s) by Hailo::__ANON__[/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/Hailo.pm:176] at line 148 of Hailo.pm |