← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:10 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/overload.pm
StatementsExecuted 7179 statements in 18.1ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
6775219.65ms9.65msoverload::::AddrRefoverload::AddrRef
2111342µs342µsoverload::::OVERLOADoverload::OVERLOAD
111308µs335µsoverload::::BEGIN@83overload::BEGIN@83
212112160µs502µsoverload::::importoverload::import
1118µs14µsoverload::::BEGIN@114overload::BEGIN@114
1117µs76µsoverload::::BEGIN@144overload::BEGIN@144
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
31500nsour $VERSION = '1.22';
4
516µ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
231100nsmy %ops_seen;
2412µsfor $category (keys %ops) {
251546µs $ops_seen{$_}++ for (split /\s+/, $ops{$category});
26}
27
28sub nil {}
29
30
# spent 342µs within overload::OVERLOAD which was called 21 times, avg 16µs/call: # 21 times (342µs+0s) by overload::import at line 59, avg 16µs/call
sub OVERLOAD {
31215µs $package = shift;
322127µs my %arg = @_;
33213µs my ($sub, $fb);
342147µs *{$package . "::(("} = \&nil; # Make it findable via fetchmethod.
352196µs for (keys %arg) {
363727µs if ($_ eq 'fallback') {
37921µs for my $sym (*{$package . "::()"}) {
3896µs *$sym = \&nil; # Make it findable via fetchmethod.
39911µs $$sym = $arg{$_};
40 }
41 } else {
422813µs warnings::warnif("overload arg '$_' is invalid")
43 unless $ops_seen{$_};
442810µs $sub = $arg{$_};
45288µs if (not ref $sub) {
461627µs $ {$package . "::(" . $_} = $sub;
47167µs $sub = \&nil;
48 }
49 #print STDERR "Setting '$ {'package'}::\cO$_' to \\&'$sub'.\n";
502843µs *{$package . "::(" . $_} = \&{ $sub };
51 }
52 }
53}
54
55
# spent 502µs (160+342) within overload::import which was called 21 times, avg 24µs/call: # once (11µs+30µs) by Path::Tiny::BEGIN@30 at line 34 of Path/Tiny.pm # once (10µs+25µs) by Pod::Simple::LinkSection::BEGIN@13 at line 19 of Pod/Simple/LinkSection.pm # once (8µs+27µs) by Exception::Class::Base::BEGIN@32 at line 32 of Exception/Class/Base.pm # once (9µs+25µs) by File::Temp::BEGIN@33 at line 34 of File/Temp.pm # once (10µs+21µs) by Devel::StackTrace::BEGIN@15 at line 16 of Devel/StackTrace.pm # once (10µs+20µs) by Email::Address::BEGIN@521 at line 521 of Email/Address.pm # once (8µs+19µs) by Perl::Critic::Policy::BEGIN@20 at line 20 of Perl/Critic/Policy.pm # once (8µs+18µs) by Perl::Critic::Violation::BEGIN@23 at line 23 of Perl/Critic/Violation.pm # once (9µs+16µs) by Path::Tiny::Error::BEGIN@1604 at line 1604 of Path/Tiny.pm # once (7µs+18µs) by File::Temp::Dir::BEGIN@1576 at line 1578 of File/Temp.pm # once (10µs+15µs) by PPI::Document::BEGIN@76 at line 76 of PPI/Document.pm # once (9µs+15µs) by Getopt::Long::CallBack::BEGIN@1506 at line 1507 of Getopt/Long.pm # once (8µs+14µs) by PPI::Element::BEGIN@41 at line 41 of PPI/Element.pm # once (7µs+11µs) by PPI::Document::Normalized::BEGIN@53 at line 53 of PPI/Document/Normalized.pm # once (5µs+11µs) by PPI::Element::BEGIN@42 at line 42 of PPI/Element.pm # once (5µs+10µs) by PPI::Document::Normalized::BEGIN@54 at line 54 of PPI/Document/Normalized.pm # once (5µs+10µs) by PPI::Document::BEGIN@77 at line 77 of PPI/Document.pm # once (5µs+10µs) by PPI::Element::BEGIN@44 at line 44 of PPI/Element.pm # once (5µs+9µs) by PPI::Element::BEGIN@46 at line 46 of PPI/Element.pm # once (5µs+9µs) by PPI::Element::BEGIN@45 at line 45 of PPI/Element.pm # once (5µs+9µs) by PPI::Element::BEGIN@43 at line 43 of PPI/Element.pm
sub import {
562130µs $package = (caller())[0];
57 # *{$package . "::OVERLOAD"} = \&OVERLOAD;
58213µs shift;
5921127µs21342µs $package->overload::OVERLOAD(@_);
# spent 342µs making 21 calls to overload::OVERLOAD, avg 16µs/call
60}
61
62sub unimport {
63 $package = (caller())[0];
64 shift;
65 *{$package . "::(("} = \&nil;
66 for (@_) {
67 warnings::warnif("overload arg '$_' is invalid")
68 unless $ops_seen{$_};
69 delete $ {$package . "::"}{$_ eq 'fallback' ? '()' : "(" .$_};
70 }
71}
72
73sub Overloaded {
74 my $package = shift;
75 $package = ref $package if ref $package;
76 mycan ($package, '()') || mycan ($package, '((');
77}
78
79sub ov_method {
80 my $globref = shift;
81 return undef unless $globref;
82 my $sub = \&{*$globref};
832220µs2343µs
# spent 335µs (308+27) within overload::BEGIN@83 which was called: # once (308µs+27µs) by Getopt::Long::CallBack::BEGIN@1506 at line 83
no overloading;
# spent 335µs making 1 call to overload::BEGIN@83 # spent 8µs making 1 call to overloading::unimport
84 return $sub if !ref $sub or $sub != \&nil;
85 return shift->can($ {*$globref});
86}
87
88sub OverloadedStringify {
89 my $package = shift;
90 $package = ref $package if ref $package;
91 #$package->can('(""')
92 ov_method mycan($package, '(""'), $package
93 or ov_method mycan($package, '(0+'), $package
94 or ov_method mycan($package, '(bool'), $package
95 or ov_method mycan($package, '(nomethod'), $package;
96}
97
98sub Method {
99 my $package = shift;
100 if(ref $package) {
101 local $@;
102 local $!;
103 require Scalar::Util;
104 $package = Scalar::Util::blessed($package);
105 return undef if !defined $package;
106 }
107 #my $meth = $package->can('(' . shift);
108 ov_method mycan($package, '(' . shift), $package;
109 #return $meth if $meth ne \&nil;
110 #return $ {*{$meth}};
111}
112
113
# spent 9.65ms within overload::AddrRef which was called 6775 times, avg 1µs/call: # 5364 times (7.55ms+0s) by Devel::StackTrace::_ref_to_string at line 84 of Devel/StackTrace.pm, avg 1µs/call # 1411 times (2.10ms+0s) by Devel::StackTrace::_ref_to_string at line 81 of Devel/StackTrace.pm, avg 1µs/call
sub AddrRef {
1142124µs220µs
# spent 14µs (8+6) within overload::BEGIN@114 which was called: # once (8µs+6µs) by Getopt::Long::CallBack::BEGIN@1506 at line 114
no overloading;
# spent 14µs making 1 call to overload::BEGIN@114 # spent 6µs making 1 call to overloading::unimport
115677517.0ms "$_[0]";
116}
117
1181900ns*StrVal = *AddrRef;
119
120sub mycan { # Real can would leave stubs.
121 my ($package, $meth) = @_;
122
123 local $@;
124 local $!;
125 require mro;
126
127 my $mro = mro::get_linear_isa($package);
128 foreach my $p (@$mro) {
129 my $fqmeth = $p . q{::} . $meth;
130 return \*{$fqmeth} if defined &{$fqmeth};
131 }
132
133 return undef;
134}
135
13612µs%constants = (
137 'integer' => 0x1000, # HINT_NEW_INTEGER
138 'float' => 0x2000, # HINT_NEW_FLOAT
139 'binary' => 0x4000, # HINT_NEW_BINARY
140 'q' => 0x8000, # HINT_NEW_STRING
141 'qr' => 0x10000, # HINT_NEW_RE
142 );
143
1442166µs2145µs
# spent 76µs (7+69) within overload::BEGIN@144 which was called: # once (7µs+69µs) by Getopt::Long::CallBack::BEGIN@1506 at line 144
use warnings::register;
# spent 76µs making 1 call to overload::BEGIN@144 # spent 69µs making 1 call to warnings::register::import
145sub constant {
146 # Arguments: what, sub
147 while (@_) {
148 if (@_ == 1) {
149 warnings::warnif ("Odd number of arguments for overload::constant");
150 last;
151 }
152 elsif (!exists $constants {$_ [0]}) {
153 warnings::warnif ("'$_[0]' is not an overloadable type");
154 }
155 elsif (!ref $_ [1] || "$_[1]" !~ /(^|=)CODE\(0x[0-9a-f]+\)$/) {
156 # Can't use C<ref $_[1] eq "CODE"> above as code references can be
157 # blessed, and C<ref> would return the package the ref is blessed into.
158 if (warnings::enabled) {
159 $_ [1] = "undef" unless defined $_ [1];
160 warnings::warn ("'$_[1]' is not a code reference");
161 }
162 }
163 else {
164 $^H{$_[0]} = $_[1];
165 $^H |= $constants{$_[0]};
166 }
167 shift, shift;
168 }
169}
170
171sub remove_constant {
172 # Arguments: what, sub
173 while (@_) {
174 delete $^H{$_[0]};
175 $^H &= ~ $constants{$_[0]};
176 shift, shift;
177 }
178}
179
18019µs1;
181
182__END__