| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Object.pm |
| Statements | Executed 11487 statements in 146ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2776 | 4 | 3 | 69.8ms | 96.4ms | Class::MOP::Object::_is_compatible_with |
| 1496 | 2 | 1 | 34.8ms | 85.0ms | Class::MOP::Object::_can_be_made_compatible_with |
| 42 | 1 | 1 | 886µs | 1.13ms | Class::MOP::Object::_real_ref_name |
| 1 | 1 | 1 | 76µs | 94µs | Class::MOP::Object::BEGIN@4 |
| 1 | 1 | 1 | 37µs | 1.52ms | Class::MOP::Object::_new |
| 1 | 1 | 1 | 37µs | 105µs | Class::MOP::Object::BEGIN@5 |
| 1 | 1 | 1 | 35µs | 183µs | Class::MOP::Object::BEGIN@7 |
| 1 | 1 | 1 | 34µs | 178µs | Class::MOP::Object::BEGIN@8 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Object::_get_compatible_metaclass |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Object::_get_compatible_metaclass_by_subclassing |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Object::_make_compatible_with |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Object::dump |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Class::MOP::Object; | ||||
| 3 | |||||
| 4 | 3 | 95µs | 2 | 112µs | # spent 94µs (76+18) within Class::MOP::Object::BEGIN@4 which was called:
# once (76µs+18µs) by base::import at line 4 # spent 94µs making 1 call to Class::MOP::Object::BEGIN@4
# spent 18µs making 1 call to strict::import |
| 5 | 3 | 102µs | 2 | 172µs | # spent 105µs (37+68) within Class::MOP::Object::BEGIN@5 which was called:
# once (37µs+68µs) by base::import at line 5 # spent 105µs making 1 call to Class::MOP::Object::BEGIN@5
# spent 68µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 97µs | 2 | 332µs | # spent 183µs (35+149) within Class::MOP::Object::BEGIN@7 which was called:
# once (35µs+149µs) by base::import at line 7 # spent 183µs making 1 call to Class::MOP::Object::BEGIN@7
# spent 149µs making 1 call to Exporter::import |
| 8 | 3 | 1.53ms | 2 | 323µs | # spent 178µs (34+145) within Class::MOP::Object::BEGIN@8 which was called:
# once (34µs+145µs) by base::import at line 8 # spent 178µs making 1 call to Class::MOP::Object::BEGIN@8
# spent 145µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 11 | 1 | 58µs | $VERSION = eval $VERSION; # spent 10µs executing statements in string eval | ||
| 12 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 13 | |||||
| 14 | # introspection | ||||
| 15 | |||||
| 16 | sub meta { | ||||
| 17 | 33 | 126µs | require Class::MOP::Class; | ||
| 18 | 33 | 1.41ms | 66 | 26.5ms | Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); # spent 26.4ms making 33 calls to Class::MOP::Class::initialize, avg 799µs/call
# spent 170µs making 33 calls to Scalar::Util::blessed, avg 5µs/call |
| 19 | } | ||||
| 20 | |||||
| 21 | # spent 1.52ms (37µs+1.48) within Class::MOP::Object::_new which was called:
# once (37µs+1.48ms) by Moose::Meta::TypeConstraint::Registry::new at line 29 of Moose/Meta/TypeConstraint/Registry.pm | ||||
| 22 | 1 | 49µs | 2 | 1.48ms | Class::MOP::class_of(shift)->new_object(@_); # spent 1.45ms making 1 call to Class::MOP::Class::new_object
# spent 33µs making 1 call to Class::MOP::class_of |
| 23 | } | ||||
| 24 | |||||
| 25 | # RANT: | ||||
| 26 | # Cmon, how many times have you written | ||||
| 27 | # the following code while debugging: | ||||
| 28 | # | ||||
| 29 | # use Data::Dumper; | ||||
| 30 | # warn Dumper $obj; | ||||
| 31 | # | ||||
| 32 | # It can get seriously annoying, so why | ||||
| 33 | # not just do this ... | ||||
| 34 | sub dump { | ||||
| 35 | my $self = shift; | ||||
| 36 | require Data::Dumper; | ||||
| 37 | local $Data::Dumper::Maxdepth = shift || 1; | ||||
| 38 | Data::Dumper::Dumper $self; | ||||
| 39 | } | ||||
| 40 | |||||
| 41 | # spent 1.13ms (886µs+239µs) within Class::MOP::Object::_real_ref_name which was called 42 times, avg 27µs/call:
# 42 times (886µs+239µs) by Class::MOP::Method::Meta::_make_compatible_with at line 75 of Class/MOP/Method/Meta.pm, avg 27µs/call | ||||
| 42 | 42 | 117µs | my $self = shift; | ||
| 43 | 42 | 1.08ms | 42 | 239µs | return blessed($self); # spent 239µs making 42 calls to Scalar::Util::blessed, avg 6µs/call |
| 44 | } | ||||
| 45 | |||||
| 46 | # spent 96.4ms (69.8+26.6) within Class::MOP::Object::_is_compatible_with which was called 2776 times, avg 35µs/call:
# 1496 times (36.0ms+14.2ms) by Class::MOP::Object::_can_be_made_compatible_with at line 55, avg 34µs/call
# 1076 times (28.2ms+10.7ms) by Class::MOP::Class::_single_metaclass_is_compatible at line 305 of Class/MOP/Class.pm, avg 36µs/call
# 162 times (4.36ms+1.18ms) by Class::MOP::Class::_class_metaclass_is_compatible at line 267 of Class/MOP/Class.pm, avg 34µs/call
# 42 times (1.23ms+584µs) by Class::MOP::Method::Meta::_make_compatible_with at line 75 of Class/MOP/Method/Meta.pm, avg 43µs/call | ||||
| 47 | 2776 | 8.56ms | my $self = shift; | ||
| 48 | 2776 | 7.58ms | my ($other_name) = @_; | ||
| 49 | |||||
| 50 | 2776 | 90.4ms | 2776 | 26.6ms | return $self->isa($other_name); # spent 26.6ms making 2776 calls to UNIVERSAL::isa, avg 10µs/call |
| 51 | } | ||||
| 52 | |||||
| 53 | # spent 85.0ms (34.8+50.2) within Class::MOP::Object::_can_be_made_compatible_with which was called 1496 times, avg 57µs/call:
# 1291 times (29.6ms+43.3ms) by Class::MOP::Class::_single_metaclass_can_be_made_compatible at line 375 of Class/MOP/Class.pm, avg 56µs/call
# 205 times (5.19ms+6.94ms) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 355 of Class/MOP/Class.pm, avg 59µs/call | ||||
| 54 | 1496 | 4.94ms | my $self = shift; | ||
| 55 | 1496 | 29.5ms | 1496 | 50.2ms | return !$self->_is_compatible_with(@_) # spent 50.2ms making 1496 calls to Class::MOP::Object::_is_compatible_with, avg 34µs/call |
| 56 | && defined($self->_get_compatible_metaclass(@_)); | ||||
| 57 | } | ||||
| 58 | |||||
| 59 | sub _make_compatible_with { | ||||
| 60 | my $self = shift; | ||||
| 61 | my ($other_name) = @_; | ||||
| 62 | |||||
| 63 | my $new_metaclass = $self->_get_compatible_metaclass($other_name); | ||||
| 64 | |||||
| 65 | confess "Can't make $self compatible with metaclass $other_name" | ||||
| 66 | unless defined $new_metaclass; | ||||
| 67 | |||||
| 68 | # can't use rebless_instance here, because it might not be an actual | ||||
| 69 | # subclass in the case of, e.g. moose role reconciliation | ||||
| 70 | $new_metaclass->meta->_force_rebless_instance($self) | ||||
| 71 | if blessed($self) ne $new_metaclass; | ||||
| 72 | |||||
| 73 | return $self; | ||||
| 74 | } | ||||
| 75 | |||||
| 76 | sub _get_compatible_metaclass { | ||||
| 77 | my $self = shift; | ||||
| 78 | my ($other_name) = @_; | ||||
| 79 | |||||
| 80 | return $self->_get_compatible_metaclass_by_subclassing($other_name); | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | sub _get_compatible_metaclass_by_subclassing { | ||||
| 84 | my $self = shift; | ||||
| 85 | my ($other_name) = @_; | ||||
| 86 | my $meta_name = blessed($self) ? $self->_real_ref_name : $self; | ||||
| 87 | |||||
| 88 | if ($meta_name->isa($other_name)) { | ||||
| 89 | return $meta_name; | ||||
| 90 | } | ||||
| 91 | elsif ($other_name->isa($meta_name)) { | ||||
| 92 | return $other_name; | ||||
| 93 | } | ||||
| 94 | |||||
| 95 | return; | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | 1 | 10µs | 1; | ||
| 99 | |||||
| 100 | __END__ |