Filename | /usr/local/lib/perl/5.18.2/Moose/Object.pm |
Statements | Executed 6154878 statements in 19.6s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1230964 | 2 | 2 | 22.2s | 67.0s | does | Moose::Object::
1 | 1 | 1 | 89µs | 90µs | BEGIN@106 | Moose::Object::
1 | 1 | 1 | 12µs | 1.77ms | BEGIN@16 | Moose::Object::
1 | 1 | 1 | 11µs | 40µs | BEGIN@15 | Moose::Object::
1 | 1 | 1 | 9µs | 19µs | BEGIN@4 | Moose::Object::
1 | 1 | 1 | 8µs | 19µs | BEGIN@79 | Moose::Object::
1 | 1 | 1 | 6µs | 10µs | BEGIN@5 | Moose::Object::
1 | 1 | 1 | 4µs | 4µs | BEGIN@13 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@7 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@10 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@11 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@9 | Moose::Object::
1 | 1 | 1 | 2µs | 2µs | BEGIN@8 | Moose::Object::
0 | 0 | 0 | 0s | 0s | BUILDALL | Moose::Object::
0 | 0 | 0 | 0s | 0s | BUILDARGS | Moose::Object::
0 | 0 | 0 | 0s | 0s | DEMOLISHALL | Moose::Object::
0 | 0 | 0 | 0s | 0s | DESTROY | Moose::Object::
0 | 0 | 0 | 0s | 0s | __ANON__[:100] | Moose::Object::
0 | 0 | 0 | 0s | 0s | __ANON__[:97] | Moose::Object::
0 | 0 | 0 | 0s | 0s | dump | Moose::Object::
0 | 0 | 0 | 0s | 0s | new | Moose::Object::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Object; | ||||
2 | 1 | 500ns | our $VERSION = '2.1604'; | ||
3 | |||||
4 | 2 | 20µs | 2 | 29µs | # spent 19µs (9+10) within Moose::Object::BEGIN@4 which was called:
# once (9µs+10µs) by Moose::BEGIN@30 at line 4 # spent 19µs making 1 call to Moose::Object::BEGIN@4
# spent 10µs making 1 call to strict::import |
5 | 2 | 20µs | 2 | 14µs | # spent 10µs (6+4) within Moose::Object::BEGIN@5 which was called:
# once (6µs+4µs) by Moose::BEGIN@30 at line 5 # spent 10µs making 1 call to Moose::Object::BEGIN@5
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 15µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@7 which was called:
# once (3µs+0s) by Moose::BEGIN@30 at line 7 # spent 3µs making 1 call to Moose::Object::BEGIN@7 |
8 | 2 | 15µs | 1 | 2µs | # spent 2µs within Moose::Object::BEGIN@8 which was called:
# once (2µs+0s) by Moose::BEGIN@30 at line 8 # spent 2µs making 1 call to Moose::Object::BEGIN@8 |
9 | 2 | 29µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@9 which was called:
# once (3µs+0s) by Moose::BEGIN@30 at line 9 # spent 3µs making 1 call to Moose::Object::BEGIN@9 |
10 | 2 | 16µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@10 which was called:
# once (3µs+0s) by Moose::BEGIN@30 at line 10 # spent 3µs making 1 call to Moose::Object::BEGIN@10 |
11 | 2 | 19µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@11 which was called:
# once (3µs+0s) by Moose::BEGIN@30 at line 11 # spent 3µs making 1 call to Moose::Object::BEGIN@11 |
12 | |||||
13 | 2 | 34µs | 1 | 4µs | # spent 4µs within Moose::Object::BEGIN@13 which was called:
# once (4µs+0s) by Moose::BEGIN@30 at line 13 # spent 4µs making 1 call to Moose::Object::BEGIN@13 |
14 | |||||
15 | 2 | 31µs | 2 | 44µs | # spent 40µs (11+28) within Moose::Object::BEGIN@15 which was called:
# once (11µs+28µs) by Moose::BEGIN@30 at line 15 # spent 40µs making 1 call to Moose::Object::BEGIN@15
# spent 5µs making 1 call to if::import |
16 | 2 | 308µs | 2 | 1.77ms | # spent 1.77ms (12µs+1.76) within Moose::Object::BEGIN@16 which was called:
# once (12µs+1.76ms) by Moose::BEGIN@30 at line 16 # spent 1.77ms making 1 call to Moose::Object::BEGIN@16
# spent 2µs making 1 call to if::import |
17 | |||||
18 | sub new { | ||||
19 | my $class = shift; | ||||
20 | my $real_class = Scalar::Util::blessed($class) || $class; | ||||
21 | |||||
22 | my $params = $real_class->BUILDARGS(@_); | ||||
23 | |||||
24 | return Class::MOP::Class->initialize($real_class)->new_object($params); | ||||
25 | } | ||||
26 | |||||
27 | sub BUILDARGS { | ||||
28 | my $class = shift; | ||||
29 | if ( scalar @_ == 1 ) { | ||||
30 | unless ( defined $_[0] && ref $_[0] eq 'HASH' ) { | ||||
31 | Moose::Util::throw_exception( "SingleParamsToNewMustBeHashRef" ); | ||||
32 | } | ||||
33 | return { %{ $_[0] } }; | ||||
34 | } | ||||
35 | elsif ( @_ % 2 ) { | ||||
36 | Carp::carp( | ||||
37 | "The new() method for $class expects a hash reference or a key/value list." | ||||
38 | . " You passed an odd number of arguments" ); | ||||
39 | return { @_, undef }; | ||||
40 | } | ||||
41 | else { | ||||
42 | return { @_ }; | ||||
43 | } | ||||
44 | } | ||||
45 | |||||
46 | sub BUILDALL { | ||||
47 | # NOTE: we ask Perl if we even | ||||
48 | # need to do this first, to avoid | ||||
49 | # extra meta level calls | ||||
50 | return unless $_[0]->can('BUILD'); | ||||
51 | my ($self, $params) = @_; | ||||
52 | foreach my $method (reverse Class::MOP::class_of($self)->find_all_methods_by_name('BUILD')) { | ||||
53 | $method->{code}->execute($self, $params); | ||||
54 | } | ||||
55 | } | ||||
56 | |||||
57 | sub DEMOLISHALL { | ||||
58 | my $self = shift; | ||||
59 | my ($in_global_destruction) = @_; | ||||
60 | |||||
61 | # NOTE: we ask Perl if we even | ||||
62 | # need to do this first, to avoid | ||||
63 | # extra meta level calls | ||||
64 | return unless $self->can('DEMOLISH'); | ||||
65 | |||||
66 | my @isa; | ||||
67 | if ( my $meta = Class::MOP::class_of($self ) ) { | ||||
68 | @isa = $meta->linearized_isa; | ||||
69 | } else { | ||||
70 | # We cannot count on being able to retrieve a previously made | ||||
71 | # metaclass, _or_ being able to make a new one during global | ||||
72 | # destruction. However, we should still be able to use mro at | ||||
73 | # that time (at least tests suggest so ;) | ||||
74 | my $class_name = ref $self; | ||||
75 | @isa = @{ mro::get_linear_isa($class_name) } | ||||
76 | } | ||||
77 | |||||
78 | foreach my $class (@isa) { | ||||
79 | 2 | 150µs | 2 | 31µs | # spent 19µs (8+12) within Moose::Object::BEGIN@79 which was called:
# once (8µs+12µs) by Moose::BEGIN@30 at line 79 # spent 19µs making 1 call to Moose::Object::BEGIN@79
# spent 12µs making 1 call to strict::unimport |
80 | my $demolish = *{"${class}::DEMOLISH"}{CODE}; | ||||
81 | $self->$demolish($in_global_destruction) | ||||
82 | if defined $demolish; | ||||
83 | } | ||||
84 | } | ||||
85 | |||||
86 | sub DESTROY { | ||||
87 | my $self = shift; | ||||
88 | |||||
89 | local $?; | ||||
90 | |||||
91 | # < doy> if the destructor is being called because an exception is thrown, then $@ will be set | ||||
92 | # < doy> but if DEMOLISH does an eval which succeeds, that will clear $@ | ||||
93 | # < doy> which is broken | ||||
94 | # < doy> try::tiny implicitly localizes $@ in the try block, which fixes that | ||||
95 | Try::Tiny::try { | ||||
96 | $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction); | ||||
97 | } | ||||
98 | Try::Tiny::catch { | ||||
99 | die $_; | ||||
100 | }; | ||||
101 | |||||
102 | return; | ||||
103 | } | ||||
104 | |||||
105 | # support for UNIVERSAL::DOES ... | ||||
106 | # spent 90µs (89+1000ns) within Moose::Object::BEGIN@106 which was called:
# once (89µs+1000ns) by Moose::BEGIN@30 at line 113 | ||||
107 | 1 | 6µs | 1 | 1µs | my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa"; # spent 1µs making 1 call to UNIVERSAL::can |
108 | 1 | 83µs | eval 'sub DOES { | ||
109 | my ( $self, $class_or_role_name ) = @_; | ||||
110 | return $self->'.$does.'($class_or_role_name) | ||||
111 | || $self->does($class_or_role_name); | ||||
112 | }'; | ||||
113 | 1 | 112µs | 1 | 90µs | } # spent 90µs making 1 call to Moose::Object::BEGIN@106 |
114 | |||||
115 | # new does() methods will be created | ||||
116 | # as appropriate see Moose::Meta::Role | ||||
117 | # spent 67.0s (22.2+44.8) within Moose::Object::does which was called 1230964 times, avg 54µs/call:
# 1230932 times (22.2s+44.8s) by Moose::Util::does_role at line 69 of Moose/Util.pm, avg 54µs/call
# 32 times (330µs+227µs) by Moose::Meta::Attribute::does at line 41 of Moose/Meta/Attribute.pm, avg 17µs/call | ||||
118 | 1230964 | 571ms | my ($self, $role_name) = @_; | ||
119 | 1230964 | 5.70s | 1230964 | 1.09s | my $class = Scalar::Util::blessed($self) || $self; # spent 1.09s making 1230964 calls to Scalar::Util::blessed, avg 883ns/call |
120 | 1230964 | 2.77s | 1230964 | 10.6s | my $meta = Class::MOP::Class->initialize($class); # spent 10.6s making 1230964 calls to Class::MOP::Class::initialize, avg 9µs/call |
121 | 1230964 | 251ms | (defined $role_name) | ||
122 | || Moose::Util::throw_exception( DoesRequiresRoleName => class_name => $meta->name ); | ||||
123 | 1230964 | 10.3s | 2461896 | 33.1s | return 1 if $meta->can('does_role') && $meta->does_role($role_name); # spent 31.8s making 1230932 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::does_role, avg 26µs/call
# spent 1.27s making 1230964 calls to UNIVERSAL::can, avg 1µs/call |
124 | 32 | 61µs | return 0; | ||
125 | } | ||||
126 | |||||
127 | sub dump { | ||||
128 | my $self = shift; | ||||
129 | require Data::Dumper; | ||||
130 | local $Data::Dumper::Maxdepth = shift if @_; | ||||
131 | Data::Dumper::Dumper $self; | ||||
132 | } | ||||
133 | |||||
134 | 1 | 2µs | 1; | ||
135 | |||||
136 | # ABSTRACT: The base object for Moose | ||||
137 | |||||
138 | __END__ |