Profile of Class/MOP/Overload.pm

← 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:10 2016

Filename | /usr/local/lib/perl/5.18.2/Class/MOP/Overload.pm
Statements | Executed 30 statements in 688µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 8µs | 16µs | Class::MOP::Overload::::BEGIN@4Class::MOP::Overload::BEGIN@4
1 | 1 | 1 | 8µs | 31µs | Class::MOP::Overload::::BEGIN@9Class::MOP::Overload::BEGIN@9
1 | 1 | 1 | 6µs | 21µs | Class::MOP::Overload::::BEGIN@11Class::MOP::Overload::BEGIN@11
1 | 1 | 1 | 6µs | 28µs | Class::MOP::Overload::::BEGIN@8Class::MOP::Overload::BEGIN@8
1 | 1 | 1 | 5µs | 8µs | Class::MOP::Overload::::BEGIN@5Class::MOP::Overload::BEGIN@5
1 | 1 | 1 | 3µs | 3µs | Class::MOP::Overload::::BEGIN@7Class::MOP::Overload::BEGIN@7
0 | 0 | 0 | 0s | 0s | Class::MOP::Overload::::__ANON__[:48]Class::MOP::Overload::__ANON__[:48]
0 | 0 | 0 | 0s | 0s | Class::MOP::Overload::::__ANON__[:54]Class::MOP::Overload::__ANON__[:54]
0 | 0 | 0 | 0s | 0s | Class::MOP::Overload::::_is_equal_toClass::MOP::Overload::_is_equal_to
0 | 0 | 0 | 0s | 0s | Class::MOP::Overload::::_set_original_overloadClass::MOP::Overload::_set_original_overload
0 | 0 | 0 | 0s | 0s | Class::MOP::Overload::::attach_to_classClass::MOP::Overload::attach_to_class
0 | 0 | 0 | 0s | 0s | Class::MOP::Overload::::cloneClass::MOP::Overload::clone
0 | 0 | 0 | 0s | 0s | Class::MOP::Overload::::is_anonymousClass::MOP::Overload::is_anonymous
0 | 0 | 0 | 0s | 0s | Class::MOP::Overload::::newClass::MOP::Overload::new
0 | 0 | 0 | 0s | 0s | Class::MOP::Overload::::original_overloadClass::MOP::Overload::original_overload

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Class::MOP::Overload;
2 | 1 | 500ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 18µs | 2 | 24µs | # spent 16µs (8+8) within Class::MOP::Overload::BEGIN@4 which was called: # once (8µs+8µs) by Class::MOP::Mixin::HasOverloads::BEGIN@7 at line 4 use strict; # spent 16µs making 1 call to Class::MOP::Overload::BEGIN@4 # spent 8µs making 1 call to strict::import
5 | 2 | 18µs | 2 | 11µs | # spent 8µs (5+3) within Class::MOP::Overload::BEGIN@5 which was called: # once (5µs+3µs) by Class::MOP::Mixin::HasOverloads::BEGIN@7 at line 5 use warnings; # spent 8µs making 1 call to Class::MOP::Overload::BEGIN@5 # spent 3µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 2 | 19µs | 1 | 3µs | # spent 3µs within Class::MOP::Overload::BEGIN@7 which was called: # once (3µs+0s) by Class::MOP::Mixin::HasOverloads::BEGIN@7 at line 7 use overload (); # spent 3µs making 1 call to Class::MOP::Overload::BEGIN@7
8 | 2 | 21µs | 2 | 50µs | # spent 28µs (6+22) within Class::MOP::Overload::BEGIN@8 which was called: # once (6µs+22µs) by Class::MOP::Mixin::HasOverloads::BEGIN@7 at line 8 use Scalar::Util qw( blessed weaken ); # spent 28µs making 1 call to Class::MOP::Overload::BEGIN@8 # spent 22µs making 1 call to Exporter::import
9 | 2 | 22µs | 2 | 54µs | # spent 31µs (8+23) within Class::MOP::Overload::BEGIN@9 which was called: # once (8µs+23µs) by Class::MOP::Mixin::HasOverloads::BEGIN@7 at line 9 use Try::Tiny; # spent 31µs making 1 call to Class::MOP::Overload::BEGIN@9 # spent 23µs making 1 call to Exporter::import
10 |  |  |  |  |
11 | 2 | 533µs | 2 | 37µs | # spent 21µs (6+16) within Class::MOP::Overload::BEGIN@11 which was called: # once (6µs+16µs) by Class::MOP::Mixin::HasOverloads::BEGIN@7 at line 11 use parent 'Class::MOP::Object'; # spent 21µs making 1 call to Class::MOP::Overload::BEGIN@11 # spent 16µs making 1 call to parent::import
12 |  |  |  |  |
13 |  |  |  |  | my %Operators = (
14 |  |  |  |  | map { $_ => 1 }
15 | 15 | 9µs |  |  | grep { $_ ne 'fallback' }
16 | 1 | 43µs |  |  | map { split /\s+/ } values %overload::ops
17 |  |  |  |  | );
18 |  |  |  |  |
19 |  |  |  |  | sub new {
20 |  |  |  |  | my ( $class, %params ) = @_;
21 |  |  |  |  |
22 |  |  |  |  | unless ( defined $params{operator} ) {
23 |  |  |  |  | $class->_throw_exception('OverloadRequiresAnOperator');
24 |  |  |  |  | }
25 |  |  |  |  | unless ( $Operators{ $params{operator} } ) {
26 |  |  |  |  | $class->_throw_exception(
27 |  |  |  |  | 'InvalidOverloadOperator',
28 |  |  |  |  | operator => $params{operator},
29 |  |  |  |  | );
30 |  |  |  |  | }
31 |  |  |  |  |
32 |  |  |  |  | unless ( defined $params{method_name} || $params{coderef} ) {
33 |  |  |  |  | $class->_throw_exception(
34 |  |  |  |  | 'OverloadRequiresAMethodNameOrCoderef',
35 |  |  |  |  | operator => $params{operator},
36 |  |  |  |  | );
37 |  |  |  |  | }
38 |  |  |  |  |
39 |  |  |  |  | if ( $params{coderef} ) {
40 |  |  |  |  | unless ( defined $params{coderef_package}
41 |  |  |  |  | && defined $params{coderef_name} ) {
42 |  |  |  |  |
43 |  |  |  |  | $class->_throw_exception('OverloadRequiresNamesForCoderef');
44 |  |  |  |  | }
45 |  |  |  |  | }
46 |  |  |  |  |
47 |  |  |  |  | if ( $params{method}
48 |  |  |  |  | && !try { $params{method}->isa('Class::MOP::Method') } ) {
49 |  |  |  |  |
50 |  |  |  |  | $class->_throw_exception('OverloadRequiresAMetaMethod');
51 |  |  |  |  | }
52 |  |  |  |  |
53 |  |  |  |  | if ( $params{associated_metaclass}
54 |  |  |  |  | && !try { $params{associated_metaclass}->isa('Class::MOP::Module') } )
55 |  |  |  |  | {
56 |  |  |  |  |
57 |  |  |  |  | $class->_throw_exception('OverloadRequiresAMetaClass');
58 |  |  |  |  | }
59 |  |  |  |  |
60 |  |  |  |  | my @optional_attrs
61 |  |  |  |  | = qw( method_name coderef coderef_package coderef_name method associated_metaclass );
62 |  |  |  |  |
63 |  |  |  |  | return bless {
64 |  |  |  |  | operator => $params{operator},
65 |  |  |  |  | map { defined $params{$_} ? ( $_ => $params{$_} ) : () }
66 |  |  |  |  | @optional_attrs
67 |  |  |  |  | },
68 |  |  |  |  | $class;
69 |  |  |  |  | }
70 |  |  |  |  |
71 |  |  |  |  | sub operator { $_[0]->{operator} }
72 |  |  |  |  |
73 |  |  |  |  | sub method_name { $_[0]->{method_name} }
74 |  |  |  |  | sub has_method_name { exists $_[0]->{method_name} }
75 |  |  |  |  |
76 |  |  |  |  | sub method { $_[0]->{method} }
77 |  |  |  |  | sub has_method { exists $_[0]->{method} }
78 |  |  |  |  |
79 |  |  |  |  | sub coderef { $_[0]->{coderef} }
80 |  |  |  |  | sub has_coderef { exists $_[0]->{coderef} }
81 |  |  |  |  |
82 |  |  |  |  | sub coderef_package { $_[0]->{coderef_package} }
83 |  |  |  |  | sub has_coderef_package { exists $_[0]->{coderef_package} }
84 |  |  |  |  |
85 |  |  |  |  | sub coderef_name { $_[0]->{coderef_name} }
86 |  |  |  |  | sub has_coderef_name { exists $_[0]->{coderef_name} }
87 |  |  |  |  |
88 |  |  |  |  | sub associated_metaclass { $_[0]->{associated_metaclass} }
89 |  |  |  |  |
90 |  |  |  |  | sub is_anonymous {
91 |  |  |  |  | my $self = shift;
92 |  |  |  |  | return $self->has_coderef && $self->coderef_name eq '__ANON__';
93 |  |  |  |  | }
94 |  |  |  |  |
95 |  |  |  |  | sub attach_to_class {
96 |  |  |  |  | my ( $self, $class ) = @_;
97 |  |  |  |  | $self->{associated_metaclass} = $class;
98 |  |  |  |  | weaken $self->{associated_metaclass};
99 |  |  |  |  | }
100 |  |  |  |  |
101 |  |  |  |  | sub clone {
102 |  |  |  |  | my $self = shift;
103 |  |  |  |  |
104 |  |  |  |  | my $clone = bless { %{$self}, @_ }, blessed($self);
105 |  |  |  |  | weaken $clone->{associated_metaclass} if $clone->{associated_metaclass};
106 |  |  |  |  |
107 |  |  |  |  | $clone->_set_original_overload($self);
108 |  |  |  |  |
109 |  |  |  |  | return $clone;
110 |  |  |  |  | }
111 |  |  |  |  |
112 |  |  |  |  | sub original_overload { $_[0]->{original_overload} }
113 |  |  |  |  | sub _set_original_overload { $_[0]->{original_overload} = $_[1] }
114 |  |  |  |  |
115 |  |  |  |  | sub _is_equal_to {
116 |  |  |  |  | my $self = shift;
117 |  |  |  |  | my $other = shift;
118 |  |  |  |  |
119 |  |  |  |  | if ( $self->has_coderef ) {
120 |  |  |  |  | return unless $other->has_coderef;
121 |  |  |  |  | return $self->coderef == $other->coderef;
122 |  |  |  |  | }
123 |  |  |  |  | else {
124 |  |  |  |  | return $self->method_name eq $other->method_name;
125 |  |  |  |  | }
126 |  |  |  |  | }
127 |  |  |  |  |
128 | 1 | 5µs |  |  | 1;
129 |  |  |  |  |
130 |  |  |  |  | # ABSTRACT: Overload Meta Object
131 |  |  |  |  |
132 |  |  |  |  | __END__