| Filename | /home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/aliased.pm |
| Statements | Executed 120 statements in 655µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 5 | 1 | 1 | 160µs | 33.8ms | aliased::_load_alias (recurses: max depth 1, inclusive time 324µs) |
| 5 | 1 | 1 | 64µs | 94µs | aliased::_make_alias |
| 5 | 5 | 2 | 38µs | 33.9ms | aliased::import (recurses: max depth 1, inclusive time 367µs) |
| 5 | 1 | 1 | 17µs | 28µs | aliased::_get_alias |
| 5 | 1 | 1 | 11µs | 11µs | aliased::CORE:subst (opcode) |
| 1 | 1 | 1 | 10µs | 22µs | aliased::BEGIN@7 |
| 1 | 1 | 1 | 7µs | 11µs | aliased::BEGIN@8 |
| 1 | 1 | 1 | 7µs | 16µs | aliased::BEGIN@44 |
| 5 | 1 | 1 | 3µs | 3µs | aliased::CORE:match (opcode) |
| 0 | 0 | 0 | 0s | 0s | aliased::__ANON__[:45] |
| 0 | 0 | 0 | 0s | 0s | aliased::__ANON__[:94] |
| 0 | 0 | 0 | 0s | 0s | aliased::_croak |
| 0 | 0 | 0 | 0s | 0s | aliased::alias |
| 0 | 0 | 0 | 0s | 0s | aliased::prefix |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package aliased; # git description: v0.33-3-g0a61221 | ||||
| 2 | # ABSTRACT: Use shorter versions of class names. | ||||
| 3 | 1 | 500ns | $aliased::VERSION = '0.34'; | ||
| 4 | 1 | 500ns | require Exporter; | ||
| 5 | 1 | 900ns | @EXPORT = qw(alias prefix); | ||
| 6 | |||||
| 7 | 2 | 22µs | 2 | 34µs | # spent 22µs (10+12) within aliased::BEGIN@7 which was called:
# once (10µs+12µs) by Data::DPath::Path::BEGIN@14 at line 7 # spent 22µs making 1 call to aliased::BEGIN@7
# spent 12µs making 1 call to strict::import |
| 8 | 2 | 144µs | 2 | 15µs | # spent 11µs (7+4) within aliased::BEGIN@8 which was called:
# once (7µs+4µs) by Data::DPath::Path::BEGIN@14 at line 8 # spent 11µs making 1 call to aliased::BEGIN@8
# spent 4µs making 1 call to warnings::import |
| 9 | |||||
| 10 | sub _croak { | ||||
| 11 | require Carp; | ||||
| 12 | Carp::croak(@_); | ||||
| 13 | } | ||||
| 14 | |||||
| 15 | # spent 33.9ms (38µs+33.8) within aliased::import which was called 5 times, avg 6.77ms/call:
# once (8µs+31.3ms) by Data::DPath::Path::BEGIN@16 at line 16 of Data/DPath/Path.pm
# once (10µs+2.20ms) by Data::DPath::Path::BEGIN@14 at line 14 of Data/DPath/Path.pm
# once (6µs+368µs) by Data::DPath::Path::BEGIN@15 at line 15 of Data/DPath/Path.pm
# once (6µs+-6µs) by Data::DPath::Context::BEGIN@15 at line 15 of Data/DPath/Context.pm
# once (8µs+-8µs) by Data::DPath::Context::BEGIN@14 at line 14 of Data/DPath/Context.pm | ||||
| 16 | # Without args, just export @EXPORT | ||||
| 17 | 5 | 2µs | goto &Exporter::import if @_ <= 1; | ||
| 18 | |||||
| 19 | 5 | 4µs | my ( $class, $package, $alias, @import ) = @_; | ||
| 20 | |||||
| 21 | 5 | 2µs | my $callpack = caller(0); | ||
| 22 | 5 | 5µs | 5 | 33.8ms | _load_alias( $package, $callpack, @import ); # spent 34.1ms making 5 calls to aliased::_load_alias, avg 6.82ms/call, recursion: max depth 1, sum of overlapping time 324µs |
| 23 | 5 | 21µs | 5 | 94µs | _make_alias( $package, $callpack, $alias ); # spent 94µs making 5 calls to aliased::_make_alias, avg 19µs/call |
| 24 | } | ||||
| 25 | |||||
| 26 | # spent 28µs (17+11) within aliased::_get_alias which was called 5 times, avg 6µs/call:
# 5 times (17µs+11µs) by aliased::_make_alias at line 35, avg 6µs/call | ||||
| 27 | 5 | 1µs | my $package = shift; | ||
| 28 | 5 | 21µs | 5 | 11µs | $package =~ s/.*(?:::|')//; # spent 11µs making 5 calls to aliased::CORE:subst, avg 2µs/call |
| 29 | 5 | 11µs | return $package; | ||
| 30 | } | ||||
| 31 | |||||
| 32 | # spent 94µs (64+30) within aliased::_make_alias which was called 5 times, avg 19µs/call:
# 5 times (64µs+30µs) by aliased::import at line 23, avg 19µs/call | ||||
| 33 | 5 | 4µs | my ( $package, $callpack, $alias ) = @_; | ||
| 34 | |||||
| 35 | 5 | 5µs | 5 | 28µs | $alias ||= _get_alias($package); # spent 28µs making 5 calls to aliased::_get_alias, avg 6µs/call |
| 36 | |||||
| 37 | 5 | 15µs | 5 | 3µs | my $destination = $alias =~ /::/ # spent 3µs making 5 calls to aliased::CORE:match, avg 520ns/call |
| 38 | ? $alias | ||||
| 39 | : "$callpack\::$alias"; | ||||
| 40 | |||||
| 41 | # need a scalar not referenced elsewhere to make the sub inlinable | ||||
| 42 | 5 | 700ns | my $pack2 = $package; | ||
| 43 | |||||
| 44 | 2 | 201µs | 2 | 26µs | # spent 16µs (7+10) within aliased::BEGIN@44 which was called:
# once (7µs+10µs) by Data::DPath::Path::BEGIN@14 at line 44 # spent 16µs making 1 call to aliased::BEGIN@44
# spent 10µs making 1 call to strict::unimport |
| 45 | 5 | 40µs | *{ $destination } = sub () { $pack2 }; | ||
| 46 | } | ||||
| 47 | |||||
| 48 | # spent 33.8ms (160µs+33.6) within aliased::_load_alias which was called 5 times, avg 6.75ms/call:
# 5 times (160µs+33.6ms) by aliased::import at line 22, avg 6.75ms/call | ||||
| 49 | 5 | 2µs | my ( $package, $callpack, @import ) = @_; | ||
| 50 | |||||
| 51 | # We don't localize $SIG{__DIE__} here because we need to be careful about | ||||
| 52 | # restoring its value if there is a failure. Very, very tricky. | ||||
| 53 | 5 | 4µs | my $sigdie = $SIG{__DIE__}; | ||
| 54 | { | ||||
| 55 | 10 | 6µs | my $code = | ||
| 56 | @import == 0 | ||||
| 57 | ? "package $callpack; use $package;" | ||||
| 58 | : "package $callpack; use $package (\@import)"; | ||||
| 59 | 5 | 117µs | eval $code; # spent 70µs executing statements in string eval # includes 2.34ms spent executing 1 call to 1 sub defined therein. # spent 65µs executing statements in string eval # includes 132µs spent executing 1 call to 1 sub defined therein. # spent 64µs executing statements in string eval # includes 139µs spent executing 1 call to 1 sub defined therein. # spent 63µs executing statements in string eval # includes 128µs spent executing 1 call to 1 sub defined therein. # spent 10µs executing statements in string eval # includes 9µs spent executing 1 call to 1 sub defined therein. | ||
| 60 | 5 | 2µs | if ( my $error = $@ ) { | ||
| 61 | $SIG{__DIE__} = $sigdie; | ||||
| 62 | _croak($error); | ||||
| 63 | } | ||||
| 64 | 5 | 6µs | $sigdie = $SIG{__DIE__} | ||
| 65 | if defined $SIG{__DIE__}; | ||||
| 66 | } | ||||
| 67 | |||||
| 68 | # Make sure a global $SIG{__DIE__} makes it out of the localization. | ||||
| 69 | 5 | 700ns | $SIG{__DIE__} = $sigdie if defined $sigdie; | ||
| 70 | 5 | 14µs | return $package; | ||
| 71 | } | ||||
| 72 | |||||
| 73 | sub alias { | ||||
| 74 | my ( $package, @import ) = @_; | ||||
| 75 | |||||
| 76 | my $callpack = scalar caller(0); | ||||
| 77 | return _load_alias( $package, $callpack, @import ); | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | sub prefix { | ||||
| 81 | my ($class) = @_; | ||||
| 82 | return sub { | ||||
| 83 | my ($name) = @_; | ||||
| 84 | my $callpack = caller(0); | ||||
| 85 | if ( not @_ ) { | ||||
| 86 | return _load_alias( $class, $callpack ); | ||||
| 87 | } | ||||
| 88 | elsif ( @_ == 1 && defined $name ) { | ||||
| 89 | return _load_alias( "${class}::$name", $callpack ); | ||||
| 90 | } | ||||
| 91 | else { | ||||
| 92 | _croak("Too many arguments to prefix('$class')"); | ||||
| 93 | } | ||||
| 94 | }; | ||||
| 95 | } | ||||
| 96 | |||||
| 97 | 1 | 3µs | 1; | ||
| 98 | |||||
| 99 | __END__ | ||||
# spent 3µs within aliased::CORE:match which was called 5 times, avg 520ns/call:
# 5 times (3µs+0s) by aliased::_make_alias at line 37, avg 520ns/call | |||||
# spent 11µs within aliased::CORE:subst which was called 5 times, avg 2µs/call:
# 5 times (11µs+0s) by aliased::_get_alias at line 28, avg 2µs/call |