← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:14 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Object.pm
StatementsExecuted 2453 statements in 3.49ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
526321.32ms1.77msClass::MOP::Object::::_is_compatible_withClass::MOP::Object::_is_compatible_with
39821988µs2.34msClass::MOP::Object::::_can_be_made_compatible_withClass::MOP::Object::_can_be_made_compatible_with
1118µs193µsClass::MOP::Object::::_newClass::MOP::Object::_new
1118µs24µsClass::MOP::Object::::BEGIN@14Class::MOP::Object::BEGIN@14
1117µs7µsClass::MOP::Object::::BEGIN@3Class::MOP::Object::BEGIN@3
1115µs18µsClass::MOP::Object::::BEGIN@10Class::MOP::Object::BEGIN@10
1115µs8µsClass::MOP::Object::::BEGIN@11Class::MOP::Object::BEGIN@11
1115µs24µ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 7µs within Class::MOP::Object::BEGIN@3 which was called: # once (7µs+0s) by base::import at line 5
BEGIN {
414µs $Class::MOP::Object::AUTHORITY = 'cpan:STEVAN';
5125µs17µs}
# spent 7µs making 1 call to Class::MOP::Object::BEGIN@3
6{
72800ns $Class::MOP::Object::VERSION = '2.1005';
8}
9
10220µs230µs
# spent 18µs (5+12) within Class::MOP::Object::BEGIN@10 which was called: # once (5µs+12µs) by base::import at line 10
use strict;
# spent 18µs making 1 call to Class::MOP::Object::BEGIN@10 # spent 12µs making 1 call to strict::import
11220µs212µs
# spent 8µs (5+3) within Class::MOP::Object::BEGIN@11 which was called: # once (5µs+3µs) by base::import at line 11
use warnings;
# spent 8µs making 1 call to Class::MOP::Object::BEGIN@11 # spent 3µs making 1 call to warnings::import
12
13219µs242µs
# spent 24µs (5+19) within Class::MOP::Object::BEGIN@13 which was called: # once (5µs+19µs) by base::import at line 13
use Carp qw(confess);
# spent 24µs making 1 call to Class::MOP::Object::BEGIN@13 # spent 18µs making 1 call to Exporter::import
142339µs240µs
# spent 24µs (8+16) within Class::MOP::Object::BEGIN@14 which was called: # once (8µs+16µs) by base::import at line 14
use Scalar::Util 'blessed';
# spent 24µs making 1 call to Class::MOP::Object::BEGIN@14 # spent 16µs making 1 call to Exporter::import
15
16# introspection
17
18sub meta {
19339µs require Class::MOP::Class;
2033177µs665.21ms Class::MOP::Class->initialize(blessed($_[0]) || $_[0]);
# spent 5.20ms making 33 calls to Class::MOP::Class::initialize, avg 158µs/call # spent 14µs making 33 calls to Scalar::Util::blessed, avg 409ns/call
21}
22
23
# spent 193µs (8+184) within Class::MOP::Object::_new which was called: # once (8µs+184µs) by Moose::Meta::TypeConstraint::Registry::new at line 33 of Moose/Meta/TypeConstraint/Registry.pm
sub _new {
2415µs2184µs Class::MOP::class_of(shift)->new_object(@_);
# spent 180µs making 1 call to Class::MOP::Class::new_object # spent 5µ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.77ms (1.32+443µs) within Class::MOP::Object::_is_compatible_with which was called 526 times, avg 3µs/call: # 398 times (1.01ms+341µs) by Class::MOP::Object::_can_be_made_compatible_with at line 57, avg 3µs/call # 108 times (263µs+91µs) by Class::MOP::Class::_single_metaclass_is_compatible at line 295 of Class/MOP/Class.pm, avg 3µs/call # 20 times (53µs+10µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 257 of Class/MOP/Class.pm, avg 3µs/call
sub _is_compatible_with {
4952667µs my $self = shift;
5052675µs my ($other_name) = @_;
51
525261.87ms526442µs return $self->isa($other_name);
# spent 442µs making 526 calls to UNIVERSAL::isa, avg 841ns/call
53}
54
55
# spent 2.34ms (988µs+1.35) within Class::MOP::Object::_can_be_made_compatible_with which was called 398 times, avg 6µs/call: # 333 times (794µs+1.10ms) by Class::MOP::Class::_single_metaclass_can_be_made_compatible at line 365 of Class/MOP/Class.pm, avg 6µs/call # 65 times (194µs+250µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 345 of Class/MOP/Class.pm, avg 7µs/call
sub _can_be_made_compatible_with {
5639859µs my $self = shift;
57398802µs3981.35ms return !$self->_is_compatible_with(@_)
# spent 1.35ms making 398 calls to Class::MOP::Object::_is_compatible_with, avg 3µ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
10012µs1;
101
102# ABSTRACT: Base class for metaclasses
103
104__END__