Profile of overload.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:25 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3/overload.pm
Statements | Executed 1511 statements in 2.30ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
114 | 5 | 2 | 1.08ms | 1.25ms | overload::::AddrRefoverload::AddrRef
17 | 1 | 1 | 610µs | 622µs | overload::::OVERLOADoverload::OVERLOAD
17 | 17 | 16 | 169µs | 791µs | overload::::importoverload::import
1 | 1 | 1 | 13µs | 74µs | overload::::BEGIN@145overload::BEGIN@145
17 | 1 | 1 | 12µs | 12µs | overload::::CORE:matchoverload::CORE:match (opcode)
0 | 0 | 0 | 0s | 0s | overload::::Methodoverload::Method
0 | 0 | 0 | 0s | 0s | overload::::Overloadedoverload::Overloaded
0 | 0 | 0 | 0s | 0s | overload::::OverloadedStringifyoverload::OverloadedStringify
0 | 0 | 0 | 0s | 0s | overload::::constantoverload::constant
0 | 0 | 0 | 0s | 0s | overload::::mycanoverload::mycan
0 | 0 | 0 | 0s | 0s | overload::::niloverload::nil
0 | 0 | 0 | 0s | 0s | overload::::ov_methodoverload::ov_method
0 | 0 | 0 | 0s | 0s | overload::::remove_constantoverload::remove_constant
0 | 0 | 0 | 0s | 0s | overload::::unimportoverload::unimport

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package overload;
2 |  |  |  |  |
3 | 1 | 400ns |  |  | our $VERSION = '1.10';
4 |  |  |  |  |
5 |  |  |  |  | sub nil {}
6 |  |  |  |  |
7 |  |  |  |  | # spent 622µs (610+12) within overload::OVERLOAD which was called 17 times, avg 37µs/call: # 17 times (610µs+12µs) by overload::import at line 34, avg 37µs/call sub OVERLOAD {
8 | 17 | 9µs |  |  | $package = shift;
9 | 17 | 76µs |  |  | my %arg = @_;
10 | 17 | 12µs |  |  | my ($sub, $fb);
11 | 17 | 94µs |  |  | $ {$package . "::OVERLOAD"}{dummy}++; # Register with magic by touching.
12 | 17 | 46µs |  |  | $fb = ${$package . "::()"}; # preserve old fallback value RT#68196
13 | 17 | 36µs |  |  | *{$package . "::()"} = \&nil; # Make it findable via fetchmethod.
14 | 17 | 38µs |  |  | for (keys %arg) {
15 | 46 | 44µs |  |  | if ($_ eq 'fallback') {
16 |  |  |  |  | $fb = $arg{$_};
17 |  |  |  |  | } else {
18 | 32 | 16µs |  |  | $sub = $arg{$_};
19 | 32 | 64µs | 17 | 12µs | if (not ref $sub and $sub !~ /::/) { # spent 12µs making 17 calls to overload::CORE:match, avg 706ns/call
20 | 17 | 43µs |  |  | $ {$package . "::(" . $_} = $sub;
21 | 17 | 8µs |  |  | $sub = \&nil;
22 |  |  |  |  | }
23 |  |  |  |  | #print STDERR "Setting `$ {'package'}::\cO$_' to \\&`$sub'.\n";
24 | 32 | 74µs |  |  | *{$package . "::(" . $_} = \&{ $sub };
25 |  |  |  |  | }
26 |  |  |  |  | }
27 | 17 | 85µs |  |  | ${$package . "::()"} = $fb; # Make it findable too (fallback only).
28 |  |  |  |  | }
29 |  |  |  |  |
30 |  |  |  |  | # spent 791µs (169+622) within overload::import which was called 17 times, avg 47µs/call: # once (10µs+76µs) by DateTime::BEGIN@59 at line 60 of DateTime.pm # once (10µs+69µs) by DateTime::Duration::BEGIN@14 at line 15 of DateTime/Duration.pm # once (11µs+45µs) by DBIx::Class::ResultSet::BEGIN@25 at line 25 of DBIx/Class/ResultSet.pm # once (11µs+42µs) by Moose::Meta::TypeConstraint::BEGIN@14 at line 17 of Moose/Meta/TypeConstraint.pm # once (11µs+41µs) by SQL::Translator::Schema::Table::BEGIN@58 at line 60 of SQL/Translator/Schema/Table.pm # once (11µs+37µs) by File::Temp::Dir::BEGIN@2407 at line 2407 of File/Temp.pm # once (8µs+35µs) by Object::Enum::BEGIN@27 at line 28 of Object/Enum.pm # once (9µs+34µs) by File::Temp::BEGIN@163 at line 163 of File/Temp.pm # once (10µs+32µs) by SQL::Translator::Schema::Field::BEGIN@57 at line 59 of SQL/Translator/Schema/Field.pm # once (10µs+32µs) by DBIx::Class::ResultSourceHandle::BEGIN@14 at line 15 of DBIx/Class/ResultSourceHandle.pm # once (11µs+29µs) by Moose::Meta::Role::Method::Required::BEGIN@14 at line 15 of Moose/Meta/Role/Method/Required.pm # once (10µs+27µs) by YAML::Tag::BEGIN@7 at line 7 of YAML/Tag.pm # once (10µs+27µs) by Class::MOP::Method::BEGIN@21 at line 21 of Class/MOP/Method.pm # once (11µs+26µs) by DBIx::Class::Exception::BEGIN@9 at line 10 of DBIx/Class/Exception.pm # once (10µs+25µs) by File::stat::BEGIN@148 at line 169 of File/stat.pm # once (9µs+26µs) by Devel::Backtrace::Point::BEGIN@26 at line 26 of Devel/Backtrace/Point.pm # once (8µs+20µs) by Devel::Backtrace::BEGIN@7 at line 7 of Devel/Backtrace.pm sub import {
31 | 17 | 39µs |  |  | $package = (caller())[0];
32 |  |  |  |  | # *{$package . "::OVERLOAD"} = \&OVERLOAD;
33 | 17 | 7µs |  |  | shift;
34 | 17 | 127µs | 17 | 622µs | $package->overload::OVERLOAD(@_); # spent 622µs making 17 calls to overload::OVERLOAD, avg 37µs/call
35 |  |  |  |  | }
36 |  |  |  |  |
37 |  |  |  |  | sub unimport {
38 |  |  |  |  | $package = (caller())[0];
39 |  |  |  |  | ${$package . "::OVERLOAD"}{dummy}++; # Upgrade the table
40 |  |  |  |  | shift;
41 |  |  |  |  | for (@_) {
42 |  |  |  |  | if ($_ eq 'fallback') {
43 |  |  |  |  | undef $ {$package . "::()"};
44 |  |  |  |  | } else {
45 |  |  |  |  | delete $ {$package . "::"}{"(" . $_};
46 |  |  |  |  | }
47 |  |  |  |  | }
48 |  |  |  |  | }
49 |  |  |  |  |
50 |  |  |  |  | sub Overloaded {
51 |  |  |  |  | my $package = shift;
52 |  |  |  |  | $package = ref $package if ref $package;
53 |  |  |  |  | $package->can('()');
54 |  |  |  |  | }
55 |  |  |  |  |
56 |  |  |  |  | sub ov_method {
57 |  |  |  |  | my $globref = shift;
58 |  |  |  |  | return undef unless $globref;
59 |  |  |  |  | my $sub = \&{*$globref};
60 |  |  |  |  | return $sub if $sub ne \&nil;
61 |  |  |  |  | return shift->can($ {*$globref});
62 |  |  |  |  | }
63 |  |  |  |  |
64 |  |  |  |  | sub OverloadedStringify {
65 |  |  |  |  | my $package = shift;
66 |  |  |  |  | $package = ref $package if ref $package;
67 |  |  |  |  | #$package->can('(""')
68 |  |  |  |  | ov_method mycan($package, '(""'), $package
69 |  |  |  |  | or ov_method mycan($package, '(0+'), $package
70 |  |  |  |  | or ov_method mycan($package, '(bool'), $package
71 |  |  |  |  | or ov_method mycan($package, '(nomethod'), $package;
72 |  |  |  |  | }
73 |  |  |  |  |
74 |  |  |  |  | sub Method {
75 |  |  |  |  | my $package = shift;
76 |  |  |  |  | if(ref $package) {
77 |  |  |  |  | local $@;
78 |  |  |  |  | local $!;
79 |  |  |  |  | require Scalar::Util;
80 |  |  |  |  | $package = Scalar::Util::blessed($package);
81 |  |  |  |  | return undef if !defined $package;
82 |  |  |  |  | }
83 |  |  |  |  | #my $meth = $package->can('(' . shift);
84 |  |  |  |  | ov_method mycan($package, '(' . shift), $package;
85 |  |  |  |  | #return $meth if $meth ne \&nil;
86 |  |  |  |  | #return $ {*{$meth}};
87 |  |  |  |  | }
88 |  |  |  |  |
89 |  |  |  |  | # spent 1.25ms (1.08+168µs) within overload::AddrRef which was called 114 times, avg 11µs/call: # 44 times (344µs+59µs) by Kwalify::Validator::validate_map at line 323 of Kwalify.pm, avg 9µs/call # 44 times (319µs+57µs) by Kwalify::Validator::validate_map at line 324 of Kwalify.pm, avg 9µs/call # 22 times (372µs+44µs) by SQL::Translator::Schema::Object::equals at line 198 of SQL/Translator/Schema/Object.pm, avg 19µs/call # 2 times (31µs+5µs) by Kwalify::Validator::validate_seq at line 279 of Kwalify.pm, avg 18µs/call # 2 times (15µs+2µs) by Kwalify::Validator::validate_seq at line 280 of Kwalify.pm, avg 9µs/call sub AddrRef {
90 | 114 | 41µs |  |  | my $package = ref $_[0];
91 | 114 | 14µs |  |  | return "$_[0]" unless $package;
92 |  |  |  |  |
93 | 114 | 19µs |  |  | local $@;
94 | 114 | 108µs |  |  | local $!;
95 | 114 | 46µs |  |  | require Scalar::Util;
96 | 114 | 232µs | 114 | 53µs | my $class = Scalar::Util::blessed($_[0]); # spent 53µs making 114 calls to Scalar::Util::blessed, avg 465ns/call
97 | 114 | 37µs |  |  | my $class_prefix = defined($class) ? "$class=" : "";
98 | 114 | 219µs | 114 | 58µs | my $type = Scalar::Util::reftype($_[0]); # spent 58µs making 114 calls to Scalar::Util::reftype, avg 508ns/call
99 | 114 | 218µs | 114 | 57µs | my $addr = Scalar::Util::refaddr($_[0]); # spent 57µs making 114 calls to Scalar::Util::refaddr, avg 498ns/call
100 | 114 | 345µs |  |  | return sprintf("$class_prefix$type(0x%x)", $addr);
101 |  |  |  |  | }
102 |  |  |  |  |
103 | 1 | 1µs |  |  | *StrVal = *AddrRef;
104 |  |  |  |  |
105 |  |  |  |  | sub mycan { # Real can would leave stubs.
106 |  |  |  |  | my ($package, $meth) = @_;
107 |  |  |  |  |
108 |  |  |  |  | local $@;
109 |  |  |  |  | local $!;
110 |  |  |  |  | require mro;
111 |  |  |  |  |
112 |  |  |  |  | my $mro = mro::get_linear_isa($package);
113 |  |  |  |  | foreach my $p (@$mro) {
114 |  |  |  |  | my $fqmeth = $p . q{::} . $meth;
115 |  |  |  |  | return \*{$fqmeth} if defined &{$fqmeth};
116 |  |  |  |  | }
117 |  |  |  |  |
118 |  |  |  |  | return undef;
119 |  |  |  |  | }
120 |  |  |  |  |
121 | 1 | 2µs |  |  | %constants = (
122 |  |  |  |  | 'integer' => 0x1000, # HINT_NEW_INTEGER
123 |  |  |  |  | 'float' => 0x2000, # HINT_NEW_FLOAT
124 |  |  |  |  | 'binary' => 0x4000, # HINT_NEW_BINARY
125 |  |  |  |  | 'q' => 0x8000, # HINT_NEW_STRING
126 |  |  |  |  | 'qr' => 0x10000, # HINT_NEW_RE
127 |  |  |  |  | );
128 |  |  |  |  |
129 | 1 | 7µs |  |  | %ops = ( with_assign => "+ - * / % ** << >> x .",
130 |  |  |  |  | assign => "+= -= *= /= %= **= <<= >>= x= .=",
131 |  |  |  |  | num_comparison => "< <= > >= == !=",
132 |  |  |  |  | '3way_comparison'=> "<=> cmp",
133 |  |  |  |  | str_comparison => "lt le gt ge eq ne",
134 |  |  |  |  | binary => '& &= | |= ^ ^=',
135 |  |  |  |  | unary => "neg ! ~",
136 |  |  |  |  | mutators => '++ --',
137 |  |  |  |  | func => "atan2 cos sin exp abs log sqrt int",
138 |  |  |  |  | conversion => 'bool "" 0+ qr',
139 |  |  |  |  | iterators => '<>',
140 |  |  |  |  | filetest => "-X",
141 |  |  |  |  | dereferencing => '${} @{} %{} &{} *{}',
142 |  |  |  |  | matching => '~~',
143 |  |  |  |  | special => 'nomethod fallback =');
144 |  |  |  |  |
145 | 3 | 182µs | 2 | 134µs | # spent 74µs (13+61) within overload::BEGIN@145 which was called: # once (13µs+61µs) by Data::OptList::BEGIN@10 at line 145 use warnings::register; # spent 74µs making 1 call to overload::BEGIN@145 # spent 61µs making 1 call to warnings::register::import
146 |  |  |  |  | sub constant {
147 |  |  |  |  | # Arguments: what, sub
148 |  |  |  |  | while (@_) {
149 |  |  |  |  | if (@_ == 1) {
150 |  |  |  |  | warnings::warnif ("Odd number of arguments for overload::constant");
151 |  |  |  |  | last;
152 |  |  |  |  | }
153 |  |  |  |  | elsif (!exists $constants {$_ [0]}) {
154 |  |  |  |  | warnings::warnif ("`$_[0]' is not an overloadable type");
155 |  |  |  |  | }
156 |  |  |  |  | elsif (!ref $_ [1] || "$_[1]" !~ /(^|=)CODE\(0x[0-9a-f]+\)$/) {
157 |  |  |  |  | # Can't use C<ref $_[1] eq "CODE"> above as code references can be
158 |  |  |  |  | # blessed, and C<ref> would return the package the ref is blessed into.
159 |  |  |  |  | if (warnings::enabled) {
160 |  |  |  |  | $_ [1] = "undef" unless defined $_ [1];
161 |  |  |  |  | warnings::warn ("`$_[1]' is not a code reference");
162 |  |  |  |  | }
163 |  |  |  |  | }
164 |  |  |  |  | else {
165 |  |  |  |  | $^H{$_[0]} = $_[1];
166 |  |  |  |  | $^H |= $constants{$_[0]};
167 |  |  |  |  | }
168 |  |  |  |  | shift, shift;
169 |  |  |  |  | }
170 |  |  |  |  | }
171 |  |  |  |  |
172 |  |  |  |  | sub remove_constant {
173 |  |  |  |  | # Arguments: what, sub
174 |  |  |  |  | while (@_) {
175 |  |  |  |  | delete $^H{$_[0]};
176 |  |  |  |  | $^H &= ~ $constants{$_[0]};
177 |  |  |  |  | shift, shift;
178 |  |  |  |  | }
179 |  |  |  |  | }
180 |  |  |  |  |
181 | 1 | 7µs |  |  | 1;
182 |  |  |  |  |
183 |  |  |  |  | __END__
|  |  |  |  | # spent 12µs within overload::CORE:match which was called 17 times, avg 706ns/call: # 17 times (12µs+0s) by overload::OVERLOAD at line 19, avg 706ns/call sub overload::CORE:match; # opcode