← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:40 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Class/MOP/Object.pm
StatementsExecuted 1493 statements in 3.58ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
286321.13ms1.48msClass::MOP::Object::::_is_compatible_withClass::MOP::Object::_is_compatible_with
278211.02ms2.45msClass::MOP::Object::::_can_be_made_compatible_withClass::MOP::Object::_can_be_made_compatible_with
11111µs11µsClass::MOP::Object::::BEGIN@3Class::MOP::Object::BEGIN@3
1119µs36µsClass::MOP::Object::::BEGIN@14Class::MOP::Object::BEGIN@14
1119µs277µsClass::MOP::Object::::_newClass::MOP::Object::_new
1119µs25µsClass::MOP::Object::::BEGIN@10Class::MOP::Object::BEGIN@10
1119µs13µsClass::MOP::Object::::BEGIN@11Class::MOP::Object::BEGIN@11
1118µs38µsClass::MOP::Object::::BEGIN@13Class::MOP::Object::BEGIN@13
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::::_real_ref_nameClass::MOP::Object::_real_ref_name
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
# spent 11µs within Class::MOP::Object::BEGIN@3 which was called: # once (11µs+0s) by base::import at line 5
BEGIN {
417µs $Class::MOP::Object::AUTHORITY = 'cpan:STEVAN';
5139µs111µs}
# spent 11µs making 1 call to Class::MOP::Object::BEGIN@3
6{
722µs $Class::MOP::Object::VERSION = '2.1005';
8}
9
10230µs241µs
# spent 25µs (9+16) within Class::MOP::Object::BEGIN@10 which was called: # once (9µs+16µs) by base::import at line 10
use strict;
# spent 25µs making 1 call to Class::MOP::Object::BEGIN@10 # spent 16µs making 1 call to strict::import
11232µs218µs
# spent 13µs (9+5) within Class::MOP::Object::BEGIN@11 which was called: # once (9µs+5µs) by base::import at line 11
use warnings;
# spent 13µs making 1 call to Class::MOP::Object::BEGIN@11 # spent 5µs making 1 call to warnings::import
12
13240µs268µs
# spent 38µs (8+30) within Class::MOP::Object::BEGIN@13 which was called: # once (8µs+30µs) by base::import at line 13
use Carp qw(confess);
# spent 38µs making 1 call to Class::MOP::Object::BEGIN@13 # spent 30µs making 1 call to Exporter::import
142513µs264µs
# spent 36µs (9+27) within Class::MOP::Object::BEGIN@14 which was called: # once (9µs+27µs) by base::import at line 14
use Scalar::Util 'blessed';
# spent 36µs making 1 call to Class::MOP::Object::BEGIN@14 # spent 27µs making 1 call to Exporter::import
15
16# introspection
17
18sub meta {
193316µs require Class::MOP::Class;
2033265µs664.19ms Class::MOP::Class->initialize(blessed($_[0]) || $_[0]);
# spent 4.17ms making 33 calls to Class::MOP::Class::initialize, avg 126µs/call # spent 21µs making 33 calls to Scalar::Util::blessed, avg 639ns/call
21}
22
23
# spent 277µs (9+268) within Class::MOP::Object::_new which was called: # once (9µs+268µs) by Moose::Meta::TypeConstraint::Registry::new at line 33 of Moose/Meta/TypeConstraint/Registry.pm
sub _new {
2417µs2268µs Class::MOP::class_of(shift)->new_object(@_);
# spent 262µs making 1 call to Class::MOP::Class::new_object # spent 7µ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 ...
36sub dump {
37 my $self = shift;
38 require Data::Dumper;
39 local $Data::Dumper::Maxdepth = shift || 1;
40 Data::Dumper::Dumper $self;
41}
42
43sub _real_ref_name {
44 my $self = shift;
45 return blessed($self);
46}
47
48
# spent 1.48ms (1.13+357µs) within Class::MOP::Object::_is_compatible_with which was called 286 times, avg 5µs/call: # 278 times (1.09ms+345µs) by Class::MOP::Object::_can_be_made_compatible_with at line 57, avg 5µs/call # 7 times (30µs+12µs) by Class::MOP::Class::_single_metaclass_is_compatible at line 295 of Class/MOP/Class.pm, avg 6µs/call # once (4µs+1000ns) by Class::MOP::Class::_class_metaclass_is_compatible at line 257 of Class/MOP/Class.pm
sub _is_compatible_with {
4928644µs my $self = shift;
5028672µs my ($other_name) = @_;
51
522861.56ms286358µs return $self->isa($other_name);
# spent 358µs making 286 calls to UNIVERSAL::isa, avg 1µs/call
53}
54
55
# spent 2.45ms (1.02+1.44) within Class::MOP::Object::_can_be_made_compatible_with which was called 278 times, avg 9µs/call: # 232 times (814µs+1.17ms) by Class::MOP::Class::_single_metaclass_can_be_made_compatible at line 365 of Class/MOP/Class.pm, avg 9µs/call # 46 times (204µs+266µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 345 of Class/MOP/Class.pm, avg 10µs/call
sub _can_be_made_compatible_with {
5627853µs my $self = shift;
57278897µs2781.44ms return !$self->_is_compatible_with(@_)
# spent 1.44ms making 278 calls to Class::MOP::Object::_is_compatible_with, avg 5µs/call
58 && defined($self->_get_compatible_metaclass(@_));
59}
60
61sub _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
78sub _get_compatible_metaclass {
79 my $self = shift;
80 my ($other_name) = @_;
81
82 return $self->_get_compatible_metaclass_by_subclassing($other_name);
83}
84
85sub _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
10014µs1;
101
102# ABSTRACT: Base class for metaclasses
103
104__END__