← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:09:56 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Object.pm
StatementsExecuted 11487 statements in 146ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
27764369.8ms96.4msClass::MOP::Object::::_is_compatible_withClass::MOP::Object::_is_compatible_with
14962134.8ms85.0msClass::MOP::Object::::_can_be_made_compatible_withClass::MOP::Object::_can_be_made_compatible_with
4211886µs1.13msClass::MOP::Object::::_real_ref_nameClass::MOP::Object::_real_ref_name
11176µs94µsClass::MOP::Object::::BEGIN@4Class::MOP::Object::BEGIN@4
11137µs1.52msClass::MOP::Object::::_newClass::MOP::Object::_new
11137µs105µsClass::MOP::Object::::BEGIN@5Class::MOP::Object::BEGIN@5
11135µs183µsClass::MOP::Object::::BEGIN@7Class::MOP::Object::BEGIN@7
11134µs178µsClass::MOP::Object::::BEGIN@8Class::MOP::Object::BEGIN@8
0000s0sClass::MOP::Object::::_get_compatible_metaclassClass::MOP::Object::_get_compatible_metaclass
0000s0sClass::MOP::Object::::_get_compatible_metaclass_by_subclassingClass::MOP::Object::_get_compatible_metaclass_by_subclassing
0000s0sClass::MOP::Object::::_make_compatible_withClass::MOP::Object::_make_compatible_with
0000s0sClass::MOP::Object::::dumpClass::MOP::Object::dump
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Class::MOP::Object;
3
4395µs2112µ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
use strict;
# spent 94µs making 1 call to Class::MOP::Object::BEGIN@4 # spent 18µs making 1 call to strict::import
53102µs2172µ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
use warnings;
# spent 105µs making 1 call to Class::MOP::Object::BEGIN@5 # spent 68µs making 1 call to warnings::import
6
7397µs2332µ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
use Carp qw(confess);
# spent 183µs making 1 call to Class::MOP::Object::BEGIN@7 # spent 149µs making 1 call to Exporter::import
831.53ms2323µ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
use Scalar::Util 'blessed';
# spent 178µs making 1 call to Class::MOP::Object::BEGIN@8 # spent 145µs making 1 call to Exporter::import
9
1015µsour $VERSION = '1.11';
11158µs$VERSION = eval $VERSION;
# spent 10µs executing statements in string eval
1214µsour $AUTHORITY = 'cpan:STEVAN';
13
14# introspection
15
16sub meta {
17661.53ms require Class::MOP::Class;
186626.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
sub _new {
22149µs21.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 ...
34sub 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
sub _real_ref_name {
42841.19ms my $self = shift;
4342239µ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
sub _is_compatible_with {
478328107ms my $self = shift;
48 my ($other_name) = @_;
49
50277626.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
sub _can_be_made_compatible_with {
54299234.4ms my $self = shift;
55149650.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
59sub _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
76sub _get_compatible_metaclass {
77 my $self = shift;
78 my ($other_name) = @_;
79
80 return $self->_get_compatible_metaclass_by_subclassing($other_name);
81}
82
83sub _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
98110µs1;
99
100__END__