← Index
NYTProf Performance Profile   « line view »
For t/optimization.t
  Run on Thu Jan 8 22:47:42 2015
Reported on Thu Jan 8 22:48:05 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/aliased.pm
StatementsExecuted 115 statements in 1000µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
511245µs50.0msaliased::::_load_aliasaliased::_load_alias (recurses: max depth 1, inclusive time 426µs)
51196µs168µsaliased::::_make_aliasaliased::_make_alias
55255µs50.2msaliased::::importaliased::import (recurses: max depth 1, inclusive time 491µs)
51153µs69µsaliased::::_get_aliasaliased::_get_alias
51116µs16µsaliased::::CORE:substaliased::CORE:subst (opcode)
11116µs33µsaliased::::BEGIN@10aliased::BEGIN@10
11112µs26µsaliased::::BEGIN@45aliased::BEGIN@45
5114µs4µsaliased::::CORE:matchaliased::CORE:match (opcode)
0000s0saliased::::__ANON__[:46]aliased::__ANON__[:46]
0000s0saliased::::__ANON__[:95]aliased::__ANON__[:95]
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;
2
31600nsour $VERSION = '0.31';
4116µs$VERSION = eval $VERSION;
# spent 2µs executing statements in string eval
5
61500nsrequire Exporter;
718µs@ISA = qw(Exporter);
811µs@EXPORT = qw(alias prefix);
9
102239µs250µs
# spent 33µs (16+17) within aliased::BEGIN@10 which was called: # once (16µs+17µs) by Data::DPath::Path::BEGIN@8 at line 10
use strict;
# spent 33µs making 1 call to aliased::BEGIN@10 # spent 17µs making 1 call to strict::import
11
12sub _croak {
13 require Carp;
14 Carp::croak(@_);
15}
16
17
# spent 50.2ms (55µs+50.1) within aliased::import which was called 5 times, avg 10.0ms/call: # once (12µs+46.5ms) by Data::DPath::Path::BEGIN@10 at line 10 of lib/Data/DPath/Path.pm # once (14µs+3.05ms) by Data::DPath::Path::BEGIN@8 at line 8 of lib/Data/DPath/Path.pm # once (10µs+532µs) by Data::DPath::Path::BEGIN@9 at line 9 of lib/Data/DPath/Path.pm # once (11µs+-11µs) by Data::DPath::Context::BEGIN@8 at line 8 of lib/Data/DPath/Context.pm # once (9µs+-9µs) by Data::DPath::Context::BEGIN@9 at line 9 of lib/Data/DPath/Context.pm
sub import {
1857µs my ( $class, $package, $alias, @import ) = @_;
19
2052µs if ( @_ <= 1 ) {
21 $class->export_to_level(1);
22 return;
23 }
24
2554µs my $callpack = caller(0);
2658µs550.0ms _load_alias( $package, $callpack, @import );
# spent 50.4ms making 5 calls to aliased::_load_alias, avg 10.1ms/call, recursion: max depth 1, sum of overlapping time 426µs
27530µs5168µs _make_alias( $package, $callpack, $alias );
# spent 168µs making 5 calls to aliased::_make_alias, avg 34µs/call
28}
29
30
# spent 69µs (53+16) within aliased::_get_alias which was called 5 times, avg 14µs/call: # 5 times (53µs+16µs) by aliased::_make_alias at line 39, avg 14µs/call
sub _get_alias {
3152µs my $package = shift;
32558µs516µs $package =~ s/.*(?:::|')//;
# spent 16µs making 5 calls to aliased::CORE:subst, avg 3µs/call
33520µs return $package;
34}
35
36
# spent 168µs (96+73) within aliased::_make_alias which was called 5 times, avg 34µs/call: # 5 times (96µs+73µs) by aliased::import at line 27, avg 34µs/call
sub _make_alias {
3755µs my ( $package, $callpack, $alias ) = @_;
38
3958µs569µs $alias ||= _get_alias($package);
# spent 69µs making 5 calls to aliased::_get_alias, avg 14µs/call
40
41522µs54µs my $destination = $alias =~ /::/
# spent 4µs making 5 calls to aliased::CORE:match, avg 740ns/call
42 ? $alias
43 : "$callpack\::$alias";
44
452286µs241µs
# spent 26µs (12+15) within aliased::BEGIN@45 which was called: # once (12µs+15µs) by Data::DPath::Path::BEGIN@8 at line 45
no strict 'refs';
# spent 26µs making 1 call to aliased::BEGIN@45 # spent 14µs making 1 call to strict::unimport
46557µs *{ $destination } = sub () { $package };
47}
48
49
# spent 50.0ms (245µs+49.8) within aliased::_load_alias which was called 5 times, avg 10.0ms/call: # 5 times (245µs+49.8ms) by aliased::import at line 26, avg 10.0ms/call
sub _load_alias {
5054µs my ( $package, $callpack, @import ) = @_;
51
52 # We don't localize $SIG{__DIE__} here because we need to be careful about
53 # restoring its value if there is a failure. Very, very tricky.
5456µs my $sigdie = $SIG{__DIE__};
55 {
561010µs my $code =
57 @import == 0
58 ? "package $callpack; use $package;"
59 : "package $callpack; use $package (\@import)";
605168µs eval $code;
# spent 99µs executing statements in string eval
# includes 2.82ms spent executing 1 call to 1 sub defined therein. # spent 79µs executing statements in string eval
# includes 142µs spent executing 1 call to 1 sub defined therein. # spent 76µs executing statements in string eval
# includes 133µs spent executing 1 call to 1 sub defined therein. # spent 74µs executing statements in string eval
# includes 138µs spent executing 1 call to 1 sub defined therein. # spent 19µs executing statements in string eval
# includes 11µs spent executing 1 call to 1 sub defined therein.
6153µs if ( my $error = $@ ) {
62 $SIG{__DIE__} = $sigdie;
63 _croak($error);
64 }
6558µs $sigdie = $SIG{__DIE__}
66 if defined $SIG{__DIE__};
67 }
68
69 # Make sure a global $SIG{__DIE__} makes it out of the localization.
7051µs $SIG{__DIE__} = $sigdie if defined $sigdie;
71519µs return $package;
72}
73
74sub alias {
75 my ( $package, @import ) = @_;
76
77 my $callpack = scalar caller(0);
78 return _load_alias( $package, $callpack, @import );
79}
80
81sub prefix {
82 my ($class) = @_;
83 return sub {
84 my ($name) = @_;
85 my $callpack = caller(0);
86 if ( not @_ ) {
87 return _load_alias( $class, $callpack );
88 }
89 elsif ( @_ == 1 && defined $name ) {
90 return _load_alias( "${class}::$name", $callpack );
91 }
92 else {
93 _croak("Too many arguments to prefix('$class')");
94 }
95 };
96}
97
9815µs1;
99__END__
 
# spent 4µs within aliased::CORE:match which was called 5 times, avg 740ns/call: # 5 times (4µs+0s) by aliased::_make_alias at line 41, avg 740ns/call
sub aliased::CORE:match; # opcode
# spent 16µs within aliased::CORE:subst which was called 5 times, avg 3µs/call: # 5 times (16µs+0s) by aliased::_get_alias at line 32, avg 3µs/call
sub aliased::CORE:subst; # opcode