← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename/usr/share/perl/5.18/overload.pm
StatementsExecuted 2397 statements in 3.66ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
184111.59ms1.87msoverload::::mycanoverload::mycan
1911513µs513µsoverload::::OVERLOADoverload::OVERLOAD
9211428µs2.30msoverload::::Overloadedoverload::Overloaded
111344µs364µsoverload::::BEGIN@83overload::BEGIN@83
191916210µs723µsoverload::::importoverload::import
1117µs75µsoverload::::BEGIN@144overload::BEGIN@144
1117µs12µsoverload::::BEGIN@114overload::BEGIN@114
0000s0soverload::::AddrRefoverload::AddrRef
0000s0soverload::::Methodoverload::Method
0000s0soverload::::OverloadedStringifyoverload::OverloadedStringify
0000s0soverload::::constantoverload::constant
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
31400nsour $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
231200nsmy %ops_seen;
2412µsfor $category (keys %ops) {
251540µs $ops_seen{$_}++ for (split /\s+/, $ops{$category});
26}
27
28sub nil {}
29
30
# spent 513µs within overload::OVERLOAD which was called 19 times, avg 27µs/call: # 19 times (513µs+0s) by overload::import at line 59, avg 27µs/call
sub OVERLOAD {
31196µs $package = shift;
321956µs my %arg = @_;
33196µs my ($sub, $fb);
341967µs *{$package . "::(("} = \&nil; # Make it findable via fetchmethod.
3519127µs for (keys %arg) {
365750µs if ($_ eq 'fallback') {
371640µs for my $sym (*{$package . "::()"}) {
381613µs *$sym = \&nil; # Make it findable via fetchmethod.
391620µs $$sym = $arg{$_};
40 }
41 } else {
424127µs warnings::warnif("overload arg '$_' is invalid")
43 unless $ops_seen{$_};
444116µs $sub = $arg{$_};
454115µs if (not ref $sub) {
46817µs $ {$package . "::(" . $_} = $sub;
4785µs $sub = \&nil;
48 }
49 #print STDERR "Setting '$ {'package'}::\cO$_' to \\&'$sub'.\n";
5041100µs *{$package . "::(" . $_} = \&{ $sub };
51 }
52 }
53}
54
55
# spent 723µs (210+513) within overload::import which was called 19 times, avg 38µs/call: # once (35µs+111µs) by Time::Seconds::BEGIN@40 at line 40 of Time/Seconds.pm # once (17µs+41µs) by URI::BEGIN@24 at line 27 of URI.pm # once (15µs+30µs) by Time::Piece::BEGIN@510 at line 510 of Time/Piece.pm # once (11µs+26µs) by JSON::XS::Boolean::BEGIN@1497 at line 1500 of JSON/XS.pm # once (10µs+24µs) by Moose::Meta::TypeConstraint::BEGIN@8 at line 11 of Moose/Meta/TypeConstraint.pm # once (13µs+21µs) by Getopt::Long::CallBack::BEGIN@1506 at line 1506 of Getopt/Long.pm # once (10µs+24µs) by Moose::Meta::Role::Method::Required::BEGIN@9 at line 11 of Moose/Meta/Role/Method/Required.pm # once (8µs+25µs) by Path::Class::Entity::BEGIN@14 at line 15 of Path/Class/Entity.pm # once (9µs+23µs) by File::stat::BEGIN@158 at line 179 of File/stat.pm # once (9µs+22µs) by Getopt::Long::Descriptive::Usage::BEGIN@171 at line 181 of Getopt/Long/Descriptive/Usage.pm # once (11µs+20µs) by File::Temp::Dir::BEGIN@2490 at line 2490 of File/Temp.pm # once (8µs+23µs) by PONAPI::Exception::BEGIN@15 at line 15 of lib/PONAPI/Exception.pm # once (10µs+21µs) by Devel::StackTrace::BEGIN@15 at line 15 of Devel/StackTrace.pm # once (9µs+21µs) by Class::MOP::Method::BEGIN@15 at line 18 of Class/MOP/Method.pm # once (7µs+22µs) by File::Temp::BEGIN@166 at line 166 of File/Temp.pm # once (8µs+19µs) by Plack::Component::BEGIN@6 at line 6 of Plack/Component.pm # once (7µs+17µs) by HTTP::Headers::ActionPack::Core::Base::BEGIN@13 at line 13 of HTTP/Headers/ActionPack/Core/Base.pm # once (7µs+14µs) by Time::Piece::BEGIN@533 at line 533 of Time/Piece.pm # once (7µs+11µs) by Time::Piece::BEGIN@575 at line 575 of Time/Piece.pm
sub import {
561942µs $package = (caller())[0];
57 # *{$package . "::OVERLOAD"} = \&OVERLOAD;
58196µs shift;
5919143µs19513µs $package->overload::OVERLOAD(@_);
# spent 513µs making 19 calls to overload::OVERLOAD, avg 27µ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
73
# spent 2.30ms (428µs+1.87) within overload::Overloaded which was called 92 times, avg 25µs/call: # 92 times (428µs+1.87ms) by Devel::OverloadInfo::is_overloaded at line 57 of Devel/OverloadInfo.pm, avg 25µs/call
sub Overloaded {
749224µs my $package = shift;
759216µs $package = ref $package if ref $package;
7692270µs1841.87ms mycan ($package, '()') || mycan ($package, '((');
# spent 1.87ms making 184 calls to overload::mycan, avg 10µs/call
77}
78
79sub ov_method {
80 my $globref = shift;
81 return undef unless $globref;
82 my $sub = \&{*$globref};
832216µs2372µs
# spent 364µs (344+21) within overload::BEGIN@83 which was called: # once (344µs+21µs) by Data::OptList::BEGIN@10 at line 83
no overloading;
# spent 364µs making 1 call to overload::BEGIN@83 # spent 7µ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
113sub AddrRef {
1142118µs216µs
# spent 12µs (7+5) within overload::BEGIN@114 which was called: # once (7µs+5µs) by Data::OptList::BEGIN@10 at line 114
no overloading;
# spent 12µs making 1 call to overload::BEGIN@114 # spent 5µs making 1 call to overloading::unimport
115 "$_[0]";
116}
117
11812µs*StrVal = *AddrRef;
119
120
# spent 1.87ms (1.59+281µs) within overload::mycan which was called 184 times, avg 10µs/call: # 184 times (1.59ms+281µs) by overload::Overloaded at line 76, avg 10µs/call
sub mycan { # Real can would leave stubs.
12118455µs my ($package, $meth) = @_;
122
12318429µs local $@;
124184318µs local $!;
12518462µs require mro;
126
127184603µs184281µs my $mro = mro::get_linear_isa($package);
# spent 281µs making 184 calls to mro::get_linear_isa, avg 2µs/call
128184101µs foreach my $p (@$mro) {
12918479µs my $fqmeth = $p . q{::} . $meth;
130184390µs return \*{$fqmeth} if defined &{$fqmeth};
131 }
132
133184381µs 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
1442179µs2142µs
# spent 75µs (7+68) within overload::BEGIN@144 which was called: # once (7µs+68µs) by Data::OptList::BEGIN@10 at line 144
use warnings::register;
# spent 75µs making 1 call to overload::BEGIN@144 # spent 68µ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
18017µs1;
181
182__END__