← Index
NYTProf Performance Profile   « line view »
For bin/benchmark-perlformance
  Run on Fri Apr 17 15:31:48 2015
Reported on Fri Apr 17 15:32:02 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/aliased.pm
StatementsExecuted 120 statements in 655µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
511160µs33.8msaliased::::_load_aliasaliased::_load_alias (recurses: max depth 1, inclusive time 324µs)
51164µs94µsaliased::::_make_aliasaliased::_make_alias
55238µs33.9msaliased::::importaliased::import (recurses: max depth 1, inclusive time 367µs)
51117µs28µsaliased::::_get_aliasaliased::_get_alias
51111µs11µsaliased::::CORE:substaliased::CORE:subst (opcode)
11110µs22µsaliased::::BEGIN@7aliased::BEGIN@7
1117µs11µsaliased::::BEGIN@8aliased::BEGIN@8
1117µs16µsaliased::::BEGIN@44aliased::BEGIN@44
5113µs3µsaliased::::CORE:matchaliased::CORE:match (opcode)
0000s0saliased::::__ANON__[:45]aliased::__ANON__[:45]
0000s0saliased::::__ANON__[:94]aliased::__ANON__[:94]
0000s0saliased::::_croakaliased::_croak
0000s0saliased::::aliasaliased::alias
0000s0saliased::::prefixaliased::prefix
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package aliased; # git description: v0.33-3-g0a61221
2# ABSTRACT: Use shorter versions of class names.
31500ns$aliased::VERSION = '0.34';
41500nsrequire Exporter;
51900ns@EXPORT = qw(alias prefix);
6
7222µs234µ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
use strict;
# spent 22µs making 1 call to aliased::BEGIN@7 # spent 12µs making 1 call to strict::import
82144µs215µ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
use warnings;
# spent 11µs making 1 call to aliased::BEGIN@8 # spent 4µs making 1 call to warnings::import
9
10sub _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
sub import {
16 # Without args, just export @EXPORT
1752µs goto &Exporter::import if @_ <= 1;
18
1954µs my ( $class, $package, $alias, @import ) = @_;
20
2152µs my $callpack = caller(0);
2255µs533.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
23521µs594µ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
sub _get_alias {
2751µs my $package = shift;
28521µs511µs $package =~ s/.*(?:::|')//;
# spent 11µs making 5 calls to aliased::CORE:subst, avg 2µs/call
29511µ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
sub _make_alias {
3354µs my ( $package, $callpack, $alias ) = @_;
34
3555µs528µs $alias ||= _get_alias($package);
# spent 28µs making 5 calls to aliased::_get_alias, avg 6µs/call
36
37515µs53µ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
425700ns my $pack2 = $package;
43
442201µs226µ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
no strict 'refs';
# spent 16µs making 1 call to aliased::BEGIN@44 # spent 10µs making 1 call to strict::unimport
45540µ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
sub _load_alias {
4952µ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.
5354µs my $sigdie = $SIG{__DIE__};
54 {
55106µs my $code =
56 @import == 0
57 ? "package $callpack; use $package;"
58 : "package $callpack; use $package (\@import)";
595117µ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.
6052µs if ( my $error = $@ ) {
61 $SIG{__DIE__} = $sigdie;
62 _croak($error);
63 }
6456µs $sigdie = $SIG{__DIE__}
65 if defined $SIG{__DIE__};
66 }
67
68 # Make sure a global $SIG{__DIE__} makes it out of the localization.
695700ns $SIG{__DIE__} = $sigdie if defined $sigdie;
70514µs return $package;
71}
72
73sub alias {
74 my ( $package, @import ) = @_;
75
76 my $callpack = scalar caller(0);
77 return _load_alias( $package, $callpack, @import );
78}
79
80sub 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
9713µs1;
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
sub aliased::CORE:match; # opcode
# 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
sub aliased::CORE:subst; # opcode