← 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/5.16.3/overload.pm
StatementsExecuted 209 statements in 1.32ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111422µs469µsoverload::::BEGIN@85overload::BEGIN@85
9121177µs177µsoverload::::AddrRefoverload::AddrRef
511110µs111µsoverload::::OVERLOADoverload::OVERLOAD
55544µs155µsoverload::::importoverload::import
11114µs24µsoverload::::BEGIN@116overload::BEGIN@116
11113µs135µsoverload::::BEGIN@146overload::BEGIN@146
111900ns900nsoverload::::CORE:matchoverload::CORE:match (opcode)
0000s0soverload::::Methodoverload::Method
0000s0soverload::::Overloadedoverload::Overloaded
0000s0soverload::::OverloadedStringifyoverload::OverloadedStringify
0000s0soverload::::constantoverload::constant
0000s0soverload::::mycanoverload::mycan
0000s0soverload::::niloverload::nil
0000s0soverload::::ov_methodoverload::ov_method
0000s0soverload::::remove_constantoverload::remove_constant
0000s0soverload::::unimportoverload::unimport
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package overload;
2
31700nsour $VERSION = '1.18';
4
518µs%ops = (
6 with_assign => "+ - * / % ** << >> x .",
7 assign => "+= -= *= /= %= **= <<= >>= x= .=",
8 num_comparison => "< <= > >= == !=",
9 '3way_comparison' => "<=> cmp",
10 str_comparison => "lt le gt ge eq ne",
11 binary => '& &= | |= ^ ^=',
12 unary => "neg ! ~",
13 mutators => '++ --',
14 func => "atan2 cos sin exp abs log sqrt int",
15 conversion => 'bool "" 0+ qr',
16 iterators => '<>',
17 filetest => "-X",
18 dereferencing => '${} @{} %{} &{} *{}',
19 matching => '~~',
20 special => 'nomethod fallback =',
21);
22
231300nsmy %ops_seen;
2413µsfor $category (keys %ops) {
251549µs $ops_seen{$_}++ for (split /\s+/, $ops{$category});
26}
27
28sub nil {}
29
30
# spent 111µs (110+900ns) within overload::OVERLOAD which was called 5 times, avg 22µs/call: # 5 times (110µs+900ns) by overload::import at line 59, avg 22µs/call
sub OVERLOAD {
3152µs $package = shift;
3258µs my %arg = @_;
3352µs my ($sub, $fb);
34520µs $ {$package . "::OVERLOAD"}{dummy}++; # Register with magic by touching.
3558µs $fb = ${$package . "::()"}; # preserve old fallback value RT#68196
36510µs *{$package . "::()"} = \&nil; # Make it findable via fetchmethod.
3758µs for (keys %arg) {
38910µs if ($_ eq 'fallback') {
39 $fb = $arg{$_};
40 } else {
4163µs warnings::warnif("overload arg '$_' is invalid")
42 unless $ops_seen{$_};
4362µs $sub = $arg{$_};
44610µs1900ns if (not ref $sub and $sub !~ /::/) {
# spent 900ns making 1 call to overload::CORE:match
4512µs $ {$package . "::(" . $_} = $sub;
461800ns $sub = \&nil;
47 }
48 #print STDERR "Setting '$ {'package'}::\cO$_' to \\&'$sub'.\n";
49612µs *{$package . "::(" . $_} = \&{ $sub };
50 }
51 }
52524µs ${$package . "::()"} = $fb; # Make it findable too (fallback only).
53}
54
55
# spent 155µs (44+111) within overload::import which was called 5 times, avg 31µs/call: # once (13µs+22µs) by Getopt::Long::CallBack::BEGIN@1505 at line 1505 of Getopt/Long.pm # once (6µs+28µs) by Exception::Class::Base::BEGIN@35 at line 35 of Exception/Class/Base.pm # once (9µs+24µs) by Devel::StackTrace::BEGIN@16 at line 16 of Devel/StackTrace.pm # once (10µs+22µs) by Text::Balanced::ErrorMsg::BEGIN@1021 at line 1021 of Text/Balanced.pm # once (8µs+16µs) by Data::DPath::Path::BEGIN@1.6 at line 1 of (eval 33)[Data/DPath/Path.pm:61]
sub import {
5658µs $package = (caller())[0];
57 # *{$package . "::OVERLOAD"} = \&OVERLOAD;
5851µs shift;
59530µs5111µs $package->overload::OVERLOAD(@_);
# spent 111µs making 5 calls to overload::OVERLOAD, avg 22µs/call
60}
61
62sub unimport {
63 $package = (caller())[0];
64 ${$package . "::OVERLOAD"}{dummy}++; # Upgrade the table
65 shift;
66 for (@_) {
67 if ($_ eq 'fallback') {
68 undef $ {$package . "::()"};
69 } else {
70 delete $ {$package . "::"}{"(" . $_};
71 }
72 }
73}
74
75sub Overloaded {
76 my $package = shift;
77 $package = ref $package if ref $package;
78 mycan ($package, '()');
79}
80
81sub ov_method {
82 my $globref = shift;
83 return undef unless $globref;
84 my $sub = \&{*$globref};
852325µs2481µs
# spent 469µs (422+47) within overload::BEGIN@85 which was called: # once (422µs+47µs) by Getopt::Long::CallBack::BEGIN@1505 at line 85
no overloading;
# spent 469µs making 1 call to overload::BEGIN@85 # spent 12µs making 1 call to overloading::unimport
86 return $sub if !ref $sub or $sub != \&nil;
87 return shift->can($ {*$globref});
88}
89
90sub OverloadedStringify {
91 my $package = shift;
92 $package = ref $package if ref $package;
93 #$package->can('(""')
94 ov_method mycan($package, '(""'), $package
95 or ov_method mycan($package, '(0+'), $package
96 or ov_method mycan($package, '(bool'), $package
97 or ov_method mycan($package, '(nomethod'), $package;
98}
99
100sub Method {
101 my $package = shift;
102 if(ref $package) {
103 local $@;
104 local $!;
105 require Scalar::Util;
106 $package = Scalar::Util::blessed($package);
107 return undef if !defined $package;
108 }
109 #my $meth = $package->can('(' . shift);
110 ov_method mycan($package, '(' . shift), $package;
111 #return $meth if $meth ne \&nil;
112 #return $ {*{$meth}};
113}
114
115
# spent 177µs within overload::AddrRef which was called 91 times, avg 2µs/call: # 83 times (158µs+0s) by Devel::StackTrace::_ref_to_string at line 82 of Devel/StackTrace.pm, avg 2µs/call # 8 times (19µs+0s) by Devel::StackTrace::_ref_to_string at line 79 of Devel/StackTrace.pm, avg 2µs/call
sub AddrRef {
1162178µs233µs
# spent 24µs (14+9) within overload::BEGIN@116 which was called: # once (14µs+9µs) by Getopt::Long::CallBack::BEGIN@1505 at line 116
no overloading;
# spent 24µs making 1 call to overload::BEGIN@116 # spent 10µs making 1 call to overloading::unimport
11791283µs "$_[0]";
118}
119
12011µs*StrVal = *AddrRef;
121
122sub mycan { # Real can would leave stubs.
123 my ($package, $meth) = @_;
124
125 local $@;
126 local $!;
127 require mro;
128
129 my $mro = mro::get_linear_isa($package);
130 foreach my $p (@$mro) {
131 my $fqmeth = $p . q{::} . $meth;
132 return \*{$fqmeth} if defined &{$fqmeth};
133 }
134
135 return undef;
136}
137
13812µs%constants = (
139 'integer' => 0x1000, # HINT_NEW_INTEGER
140 'float' => 0x2000, # HINT_NEW_FLOAT
141 'binary' => 0x4000, # HINT_NEW_BINARY
142 'q' => 0x8000, # HINT_NEW_STRING
143 'qr' => 0x10000, # HINT_NEW_RE
144 );
145
1462298µs2257µs
# spent 135µs (13+122) within overload::BEGIN@146 which was called: # once (13µs+122µs) by Getopt::Long::CallBack::BEGIN@1505 at line 146
use warnings::register;
# spent 135µs making 1 call to overload::BEGIN@146 # spent 122µs making 1 call to warnings::register::import
147sub constant {
148 # Arguments: what, sub
149 while (@_) {
150 if (@_ == 1) {
151 warnings::warnif ("Odd number of arguments for overload::constant");
152 last;
153 }
154 elsif (!exists $constants {$_ [0]}) {
155 warnings::warnif ("'$_[0]' is not an overloadable type");
156 }
157 elsif (!ref $_ [1] || "$_[1]" !~ /(^|=)CODE\(0x[0-9a-f]+\)$/) {
158 # Can't use C<ref $_[1] eq "CODE"> above as code references can be
159 # blessed, and C<ref> would return the package the ref is blessed into.
160 if (warnings::enabled) {
161 $_ [1] = "undef" unless defined $_ [1];
162 warnings::warn ("'$_[1]' is not a code reference");
163 }
164 }
165 else {
166 $^H{$_[0]} = $_[1];
167 $^H |= $constants{$_[0]};
168 }
169 shift, shift;
170 }
171}
172
173sub remove_constant {
174 # Arguments: what, sub
175 while (@_) {
176 delete $^H{$_[0]};
177 $^H &= ~ $constants{$_[0]};
178 shift, shift;
179 }
180}
181
18219µs1;
183
184__END__
 
# spent 900ns within overload::CORE:match which was called: # once (900ns+0s) by overload::OVERLOAD at line 44
sub overload::CORE:match; # opcode