Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Object.pm |
Statements | Executed 54 statements in 1.25ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 4.02ms | 4.69ms | dump | Moose::Object::
1 | 1 | 1 | 210µs | 232µs | BEGIN@19 | Moose::Object::
1 | 1 | 1 | 49µs | 50µs | BEGIN@108 | Moose::Object::
4 | 1 | 1 | 34µs | 60µs | does | Moose::Object::
1 | 1 | 1 | 13µs | 1.66ms | BEGIN@20 | Moose::Object::
1 | 1 | 1 | 8µs | 8µs | BEGIN@3 | Moose::Object::
1 | 1 | 1 | 6µs | 16µs | BEGIN@85 | Moose::Object::
1 | 1 | 1 | 6µs | 9µs | BEGIN@11 | Moose::Object::
1 | 1 | 1 | 6µs | 16µs | BEGIN@10 | Moose::Object::
1 | 1 | 1 | 2µs | 2µs | BEGIN@13 | Moose::Object::
1 | 1 | 1 | 2µs | 2µs | BEGIN@14 | Moose::Object::
1 | 1 | 1 | 2µs | 2µs | BEGIN@15 | Moose::Object::
1 | 1 | 1 | 2µs | 2µs | BEGIN@16 | Moose::Object::
1 | 1 | 1 | 2µs | 2µs | BEGIN@17 | 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__[:102] | Moose::Object::
0 | 0 | 0 | 0s | 0s | __ANON__[:99] | Moose::Object::
0 | 0 | 0 | 0s | 0s | new | Moose::Object::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Moose::Object; | ||||
3 | # spent 8µs within Moose::Object::BEGIN@3 which was called:
# once (8µs+0s) by Moose::BEGIN@33 at line 5 | ||||
4 | 1 | 4µs | $Moose::Object::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 30µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Object::BEGIN@3 |
6 | { | ||||
7 | 2 | 900ns | $Moose::Object::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 22µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Object::BEGIN@10 which was called:
# once (6µs+10µs) by Moose::BEGIN@33 at line 10 # spent 16µs making 1 call to Moose::Object::BEGIN@10
# spent 10µs making 1 call to strict::import |
11 | 2 | 18µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Object::BEGIN@11 which was called:
# once (6µs+3µs) by Moose::BEGIN@33 at line 11 # spent 9µs making 1 call to Moose::Object::BEGIN@11
# spent 3µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 16µs | 1 | 2µs | # spent 2µs within Moose::Object::BEGIN@13 which was called:
# once (2µs+0s) by Moose::BEGIN@33 at line 13 # spent 2µs making 1 call to Moose::Object::BEGIN@13 |
14 | 2 | 16µs | 1 | 2µs | # spent 2µs within Moose::Object::BEGIN@14 which was called:
# once (2µs+0s) by Moose::BEGIN@33 at line 14 # spent 2µs making 1 call to Moose::Object::BEGIN@14 |
15 | 2 | 15µs | 1 | 2µs | # spent 2µs within Moose::Object::BEGIN@15 which was called:
# once (2µs+0s) by Moose::BEGIN@33 at line 15 # spent 2µs making 1 call to Moose::Object::BEGIN@15 |
16 | 2 | 15µs | 1 | 2µs | # spent 2µs within Moose::Object::BEGIN@16 which was called:
# once (2µs+0s) by Moose::BEGIN@33 at line 16 # spent 2µs making 1 call to Moose::Object::BEGIN@16 |
17 | 2 | 24µs | 1 | 2µs | # spent 2µs within Moose::Object::BEGIN@17 which was called:
# once (2µs+0s) by Moose::BEGIN@33 at line 17 # spent 2µs making 1 call to Moose::Object::BEGIN@17 |
18 | |||||
19 | 2 | 230µs | 2 | 235µs | # spent 232µs (210+22) within Moose::Object::BEGIN@19 which was called:
# once (210µs+22µs) by Moose::BEGIN@33 at line 19 # spent 232µs making 1 call to Moose::Object::BEGIN@19
# spent 2µs making 1 call to if::import |
20 | 2 | 319µs | 2 | 1.66ms | # spent 1.66ms (13µs+1.64) within Moose::Object::BEGIN@20 which was called:
# once (13µs+1.64ms) by Moose::BEGIN@33 at line 20 # spent 1.66ms making 1 call to Moose::Object::BEGIN@20
# spent 2µs making 1 call to if::import |
21 | |||||
22 | sub new { | ||||
23 | my $class = shift; | ||||
24 | my $real_class = Scalar::Util::blessed($class) || $class; | ||||
25 | |||||
26 | my $params = $real_class->BUILDARGS(@_); | ||||
27 | |||||
28 | return Class::MOP::Class->initialize($real_class)->new_object($params); | ||||
29 | } | ||||
30 | |||||
31 | sub BUILDARGS { | ||||
32 | my $class = shift; | ||||
33 | if ( scalar @_ == 1 ) { | ||||
34 | unless ( defined $_[0] && ref $_[0] eq 'HASH' ) { | ||||
35 | Class::MOP::class_of($class)->throw_error( | ||||
36 | "Single parameters to new() must be a HASH ref", | ||||
37 | data => $_[0] ); | ||||
38 | } | ||||
39 | return { %{ $_[0] } }; | ||||
40 | } | ||||
41 | elsif ( @_ % 2 ) { | ||||
42 | Carp::carp( | ||||
43 | "The new() method for $class expects a hash reference or a key/value list." | ||||
44 | . " You passed an odd number of arguments" ); | ||||
45 | return { @_, undef }; | ||||
46 | } | ||||
47 | else { | ||||
48 | return {@_}; | ||||
49 | } | ||||
50 | } | ||||
51 | |||||
52 | sub BUILDALL { | ||||
53 | # NOTE: we ask Perl if we even | ||||
54 | # need to do this first, to avoid | ||||
55 | # extra meta level calls | ||||
56 | return unless $_[0]->can('BUILD'); | ||||
57 | my ($self, $params) = @_; | ||||
58 | foreach my $method (reverse Class::MOP::class_of($self)->find_all_methods_by_name('BUILD')) { | ||||
59 | $method->{code}->execute($self, $params); | ||||
60 | } | ||||
61 | } | ||||
62 | |||||
63 | sub DEMOLISHALL { | ||||
64 | my $self = shift; | ||||
65 | my ($in_global_destruction) = @_; | ||||
66 | |||||
67 | # NOTE: we ask Perl if we even | ||||
68 | # need to do this first, to avoid | ||||
69 | # extra meta level calls | ||||
70 | return unless $self->can('DEMOLISH'); | ||||
71 | |||||
72 | my @isa; | ||||
73 | if ( my $meta = Class::MOP::class_of($self ) ) { | ||||
74 | @isa = $meta->linearized_isa; | ||||
75 | } else { | ||||
76 | # We cannot count on being able to retrieve a previously made | ||||
77 | # metaclass, _or_ being able to make a new one during global | ||||
78 | # destruction. However, we should still be able to use mro at | ||||
79 | # that time (at least tests suggest so ;) | ||||
80 | my $class_name = ref $self; | ||||
81 | @isa = @{ mro::get_linear_isa($class_name) } | ||||
82 | } | ||||
83 | |||||
84 | foreach my $class (@isa) { | ||||
85 | 2 | 146µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Object::BEGIN@85 which was called:
# once (6µs+10µs) by Moose::BEGIN@33 at line 85 # spent 16µs making 1 call to Moose::Object::BEGIN@85
# spent 10µs making 1 call to strict::unimport |
86 | my $demolish = *{"${class}::DEMOLISH"}{CODE}; | ||||
87 | $self->$demolish($in_global_destruction) | ||||
88 | if defined $demolish; | ||||
89 | } | ||||
90 | } | ||||
91 | |||||
92 | sub DESTROY { | ||||
93 | my $self = shift; | ||||
94 | |||||
95 | local $?; | ||||
96 | |||||
97 | Try::Tiny::try { | ||||
98 | $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction); | ||||
99 | } | ||||
100 | Try::Tiny::catch { | ||||
101 | die $_; | ||||
102 | }; | ||||
103 | |||||
104 | return; | ||||
105 | } | ||||
106 | |||||
107 | # support for UNIVERSAL::DOES ... | ||||
108 | # spent 50µs (49+900ns) within Moose::Object::BEGIN@108 which was called:
# once (49µs+900ns) by Moose::BEGIN@33 at line 115 | ||||
109 | 1 | 5µs | 1 | 900ns | my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa"; # spent 900ns making 1 call to UNIVERSAL::can |
110 | 1 | 45µs | eval 'sub DOES { | ||
111 | my ( $self, $class_or_role_name ) = @_; | ||||
112 | return $self->'.$does.'($class_or_role_name) | ||||
113 | || $self->does($class_or_role_name); | ||||
114 | }'; | ||||
115 | 1 | 118µs | 1 | 50µs | } # spent 50µs making 1 call to Moose::Object::BEGIN@108 |
116 | |||||
117 | # new does() methods will be created | ||||
118 | # as appropriate see Moose::Meta::Role | ||||
119 | # spent 60µs (34+26) within Moose::Object::does which was called 4 times, avg 15µs/call:
# 4 times (34µs+26µs) by Moose::Meta::Attribute::does at line 47 of Moose/Meta/Attribute.pm, avg 15µs/call | ||||
120 | 4 | 2µs | my ($self, $role_name) = @_; | ||
121 | 4 | 10µs | 4 | 2µs | my $class = Scalar::Util::blessed($self) || $self; # spent 2µs making 4 calls to Scalar::Util::blessed, avg 375ns/call |
122 | 4 | 6µs | 4 | 17µs | my $meta = Class::MOP::Class->initialize($class); # spent 17µs making 4 calls to Class::MOP::Class::initialize, avg 4µs/call |
123 | 4 | 600ns | (defined $role_name) | ||
124 | || $meta->throw_error("You must supply a role name to does()"); | ||||
125 | 4 | 15µs | 4 | 7µs | return 1 if $meta->can('does_role') && $meta->does_role($role_name); # spent 7µs making 4 calls to UNIVERSAL::can, avg 2µs/call |
126 | 4 | 8µs | return 0; | ||
127 | } | ||||
128 | |||||
129 | # spent 4.69ms (4.02+671µs) within Moose::Object::dump which was called:
# once (4.02ms+671µs) by main::RUNTIME at line 27 of examples/Atom-timer.pl | ||||
130 | 1 | 400ns | my $self = shift; | ||
131 | 1 | 176µs | require Data::Dumper; | ||
132 | 1 | 400ns | local $Data::Dumper::Maxdepth = shift if @_; | ||
133 | 1 | 6µs | 1 | 109µs | Data::Dumper::Dumper $self; # spent 109µs making 1 call to Data::Dumper::Dumper |
134 | } | ||||
135 | |||||
136 | 1 | 3µs | 1; | ||
137 | |||||
138 | # ABSTRACT: The base object for Moose | ||||
139 | |||||
140 | __END__ |