| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Object.pm |
| Statements | Executed 2013 statements in 4.31ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 418 | 3 | 2 | 1.50ms | 2.13ms | Class::MOP::Object::_is_compatible_with |
| 338 | 2 | 1 | 1.20ms | 2.92ms | Class::MOP::Object::_can_be_made_compatible_with |
| 1 | 1 | 1 | 8µs | 306µs | Class::MOP::Object::_new |
| 1 | 1 | 1 | 8µs | 8µs | Class::MOP::Object::BEGIN@3 |
| 1 | 1 | 1 | 6µs | 14µs | Class::MOP::Object::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 8µs | Class::MOP::Object::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 23µs | Class::MOP::Object::BEGIN@14 |
| 1 | 1 | 1 | 5µs | 31µs | Class::MOP::Object::BEGIN@13 |
| 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::_real_ref_name |
| 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 | # spent 8µs within Class::MOP::Object::BEGIN@3 which was called:
# once (8µs+0s) by base::import at line 5 | ||||
| 4 | 1 | 4µs | $Class::MOP::Object::AUTHORITY = 'cpan:STEVAN'; | ||
| 5 | 1 | 20µs | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::Object::BEGIN@3 |
| 6 | { | ||||
| 7 | 2 | 1µs | $Class::MOP::Object::VERSION = '2.0602'; | ||
| 8 | } | ||||
| 9 | |||||
| 10 | 3 | 15µs | 2 | 10µs | # spent 8µs (6+2) within Class::MOP::Object::BEGIN@10 which was called:
# once (6µs+2µs) by base::import at line 10 # spent 8µs making 1 call to Class::MOP::Object::BEGIN@10
# spent 2µs making 1 call to strict::import |
| 11 | 3 | 19µs | 2 | 21µs | # spent 14µs (6+8) within Class::MOP::Object::BEGIN@11 which was called:
# once (6µs+8µs) by base::import at line 11 # spent 14µs making 1 call to Class::MOP::Object::BEGIN@11
# spent 8µs making 1 call to warnings::import |
| 12 | |||||
| 13 | 3 | 17µs | 2 | 57µs | # spent 31µs (5+26) within Class::MOP::Object::BEGIN@13 which was called:
# once (5µs+26µs) by base::import at line 13 # spent 31µs making 1 call to Class::MOP::Object::BEGIN@13
# spent 26µs making 1 call to Exporter::import |
| 14 | 3 | 337µs | 2 | 41µs | # spent 23µs (6+18) within Class::MOP::Object::BEGIN@14 which was called:
# once (6µs+18µs) by base::import at line 14 # spent 23µs making 1 call to Class::MOP::Object::BEGIN@14
# spent 18µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | # introspection | ||||
| 17 | |||||
| 18 | sub meta { | ||||
| 19 | 66 | 208µs | require Class::MOP::Class; | ||
| 20 | 66 | 3.64ms | Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); # spent 3.62ms making 33 calls to Class::MOP::Class::initialize, avg 110µs/call
# spent 18µs making 33 calls to Scalar::Util::blessed, avg 558ns/call | ||
| 21 | } | ||||
| 22 | |||||
| 23 | # spent 306µs (8+298) within Class::MOP::Object::_new which was called:
# once (8µs+298µs) by Moose::Meta::TypeConstraint::Registry::new at line 33 of Moose/Meta/TypeConstraint/Registry.pm | ||||
| 24 | 1 | 8µs | 2 | 298µs | Class::MOP::class_of(shift)->new_object(@_); # spent 290µs making 1 call to Class::MOP::Class::new_object
# spent 8µs making 1 call to Class::MOP::class_of |
| 25 | } | ||||
| 26 | |||||
| 27 | # RANT: | ||||
| 28 | # Cmon, how many times have you written | ||||
| 29 | # the following code while debugging: | ||||
| 30 | # | ||||
| 31 | # use Data::Dumper; | ||||
| 32 | # warn Dumper $obj; | ||||
| 33 | # | ||||
| 34 | # It can get seriously annoying, so why | ||||
| 35 | # not just do this ... | ||||
| 36 | sub dump { | ||||
| 37 | my $self = shift; | ||||
| 38 | require Data::Dumper; | ||||
| 39 | local $Data::Dumper::Maxdepth = shift || 1; | ||||
| 40 | Data::Dumper::Dumper $self; | ||||
| 41 | } | ||||
| 42 | |||||
| 43 | sub _real_ref_name { | ||||
| 44 | my $self = shift; | ||||
| 45 | return blessed($self); | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | # spent 2.13ms (1.50+631µs) within Class::MOP::Object::_is_compatible_with which was called 418 times, avg 5µs/call:
# 338 times (1.20ms+514µs) by Class::MOP::Object::_can_be_made_compatible_with at line 57, avg 5µs/call
# 70 times (267µs+108µs) by Class::MOP::Class::_single_metaclass_is_compatible at line 295 of Class/MOP/Class.pm, avg 5µs/call
# 10 times (37µs+9µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 257 of Class/MOP/Class.pm, avg 5µs/call | ||||
| 49 | 1254 | 2.49ms | my $self = shift; | ||
| 50 | my ($other_name) = @_; | ||||
| 51 | |||||
| 52 | 418 | 631µs | return $self->isa($other_name); # spent 631µs making 418 calls to UNIVERSAL::isa, avg 2µs/call | ||
| 53 | } | ||||
| 54 | |||||
| 55 | # spent 2.92ms (1.20+1.71) within Class::MOP::Object::_can_be_made_compatible_with which was called 338 times, avg 9µs/call:
# 285 times (940µs+1.41ms) by Class::MOP::Class::_single_metaclass_can_be_made_compatible at line 365 of Class/MOP/Class.pm, avg 8µs/call
# 53 times (263µs+298µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 345 of Class/MOP/Class.pm, avg 11µs/call | ||||
| 56 | 676 | 1.19ms | my $self = shift; | ||
| 57 | 338 | 1.71ms | return !$self->_is_compatible_with(@_) # spent 1.71ms making 338 calls to Class::MOP::Object::_is_compatible_with, avg 5µs/call | ||
| 58 | && defined($self->_get_compatible_metaclass(@_)); | ||||
| 59 | } | ||||
| 60 | |||||
| 61 | sub _make_compatible_with { | ||||
| 62 | my $self = shift; | ||||
| 63 | my ($other_name) = @_; | ||||
| 64 | |||||
| 65 | my $new_metaclass = $self->_get_compatible_metaclass($other_name); | ||||
| 66 | |||||
| 67 | confess "Can't make $self compatible with metaclass $other_name" | ||||
| 68 | unless defined $new_metaclass; | ||||
| 69 | |||||
| 70 | # can't use rebless_instance here, because it might not be an actual | ||||
| 71 | # subclass in the case of, e.g. moose role reconciliation | ||||
| 72 | $new_metaclass->meta->_force_rebless_instance($self) | ||||
| 73 | if blessed($self) ne $new_metaclass; | ||||
| 74 | |||||
| 75 | return $self; | ||||
| 76 | } | ||||
| 77 | |||||
| 78 | sub _get_compatible_metaclass { | ||||
| 79 | my $self = shift; | ||||
| 80 | my ($other_name) = @_; | ||||
| 81 | |||||
| 82 | return $self->_get_compatible_metaclass_by_subclassing($other_name); | ||||
| 83 | } | ||||
| 84 | |||||
| 85 | sub _get_compatible_metaclass_by_subclassing { | ||||
| 86 | my $self = shift; | ||||
| 87 | my ($other_name) = @_; | ||||
| 88 | my $meta_name = blessed($self) ? $self->_real_ref_name : $self; | ||||
| 89 | |||||
| 90 | if ($meta_name->isa($other_name)) { | ||||
| 91 | return $meta_name; | ||||
| 92 | } | ||||
| 93 | elsif ($other_name->isa($meta_name)) { | ||||
| 94 | return $other_name; | ||||
| 95 | } | ||||
| 96 | |||||
| 97 | return; | ||||
| 98 | } | ||||
| 99 | |||||
| 100 | 1 | 3µs | 1; | ||
| 101 | |||||
| 102 | # ABSTRACT: Base class for metaclasses | ||||
| 103 | |||||
| - - | |||||
| 106 | =pod | ||||
| 107 | |||||
| 108 | =head1 NAME | ||||
| 109 | |||||
| 110 | Class::MOP::Object - Base class for metaclasses | ||||
| 111 | |||||
| 112 | =head1 VERSION | ||||
| 113 | |||||
| 114 | version 2.0602 | ||||
| 115 | |||||
| 116 | =head1 DESCRIPTION | ||||
| 117 | |||||
| 118 | This class is a very minimal base class for metaclasses. | ||||
| 119 | |||||
| 120 | =head1 METHODS | ||||
| 121 | |||||
| 122 | This class provides a few methods which are useful in all metaclasses. | ||||
| 123 | |||||
| 124 | =over 4 | ||||
| 125 | |||||
| 126 | =item B<< Class::MOP::???->meta >> | ||||
| 127 | |||||
| 128 | This returns a L<Class::MOP::Class> object. | ||||
| 129 | |||||
| 130 | =item B<< $metaobject->dump($max_depth) >> | ||||
| 131 | |||||
| 132 | This method uses L<Data::Dumper> to dump the object. You can pass an | ||||
| 133 | optional maximum depth, which will set C<$Data::Dumper::Maxdepth>. The | ||||
| 134 | default maximum depth is 1. | ||||
| 135 | |||||
| 136 | =back | ||||
| 137 | |||||
| 138 | =head1 AUTHOR | ||||
| 139 | |||||
| 140 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
| 141 | |||||
| 142 | =head1 COPYRIGHT AND LICENSE | ||||
| 143 | |||||
| 144 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
| 145 | |||||
| 146 | This is free software; you can redistribute it and/or modify it under | ||||
| 147 | the same terms as the Perl 5 programming language system itself. | ||||
| 148 | |||||
| 149 | =cut | ||||
| 150 | |||||
| 151 | |||||
| 152 | __END__ |