Filename | /usr/local/lib/perl/5.14.2/Moose/Object.pm |
Statements | Executed 90 statements in 1.31ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 215µs | 241µs | BEGIN@19 | Moose::Object::
5 | 3 | 2 | 86µs | 297µs | DESTROY | Moose::Object::
1 | 1 | 1 | 62µs | 64µs | BEGIN@108 | Moose::Object::
3 | 3 | 2 | 54µs | 1.06ms | new | Moose::Object::
5 | 1 | 1 | 24µs | 34µs | DEMOLISHALL | Moose::Object::
1 | 1 | 1 | 14µs | 31µs | BEGIN@85 | Moose::Object::
1 | 1 | 1 | 13µs | 2.08ms | BEGIN@20 | Moose::Object::
3 | 1 | 1 | 13µs | 13µs | BUILDARGS | Moose::Object::
3 | 1 | 1 | 11µs | 15µs | BUILDALL | Moose::Object::
1 | 1 | 1 | 9µs | 9µs | BEGIN@3 | Moose::Object::
1 | 1 | 1 | 8µs | 11µs | BEGIN@10 | Moose::Object::
1 | 1 | 1 | 7µs | 12µs | BEGIN@11 | Moose::Object::
1 | 1 | 1 | 4µs | 4µs | BEGIN@13 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@14 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@16 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@15 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@17 | 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 | does | Moose::Object::
0 | 0 | 0 | 0s | 0s | dump | Moose::Object::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Moose::Object; | ||||
3 | # spent 9µs within Moose::Object::BEGIN@3 which was called:
# once (9µs+0s) by Moose::BEGIN@33 at line 5 | ||||
4 | 1 | 5µs | $Moose::Object::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 30µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Object::BEGIN@3 |
6 | { | ||||
7 | 2 | 1µs | $Moose::Object::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 22µs | 2 | 14µs | # spent 11µs (8+3) within Moose::Object::BEGIN@10 which was called:
# once (8µs+3µs) by Moose::BEGIN@33 at line 10 # spent 11µs making 1 call to Moose::Object::BEGIN@10
# spent 3µs making 1 call to strict::import |
11 | 2 | 25µs | 2 | 17µs | # spent 12µs (7+5) within Moose::Object::BEGIN@11 which was called:
# once (7µs+5µs) by Moose::BEGIN@33 at line 11 # spent 12µs making 1 call to Moose::Object::BEGIN@11
# spent 5µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 18µs | 1 | 4µs | # spent 4µs within Moose::Object::BEGIN@13 which was called:
# once (4µs+0s) by Moose::BEGIN@33 at line 13 # spent 4µs making 1 call to Moose::Object::BEGIN@13 |
14 | 2 | 17µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@14 which was called:
# once (3µs+0s) by Moose::BEGIN@33 at line 14 # spent 3µs making 1 call to Moose::Object::BEGIN@14 |
15 | 2 | 16µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@15 which was called:
# once (3µs+0s) by Moose::BEGIN@33 at line 15 # spent 3µs making 1 call to Moose::Object::BEGIN@15 |
16 | 2 | 16µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@16 which was called:
# once (3µs+0s) by Moose::BEGIN@33 at line 16 # spent 3µs making 1 call to Moose::Object::BEGIN@16 |
17 | 2 | 33µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@17 which was called:
# once (3µs+0s) by Moose::BEGIN@33 at line 17 # spent 3µs making 1 call to Moose::Object::BEGIN@17 |
18 | |||||
19 | 2 | 235µs | 2 | 245µs | # spent 241µs (215+27) within Moose::Object::BEGIN@19 which was called:
# once (215µs+27µs) by Moose::BEGIN@33 at line 19 # spent 241µs making 1 call to Moose::Object::BEGIN@19
# spent 4µs making 1 call to if::import |
20 | 2 | 315µs | 2 | 2.08ms | # spent 2.08ms (13µs+2.06) within Moose::Object::BEGIN@20 which was called:
# once (13µs+2.06ms) by Moose::BEGIN@33 at line 20 # spent 2.08ms making 1 call to Moose::Object::BEGIN@20
# spent 3µs making 1 call to if::import |
21 | |||||
22 | # spent 1.06ms (54µs+1.01) within Moose::Object::new which was called 3 times, avg 355µs/call:
# once (24µs+422µs) by main::RUNTIME at line 11 of mentat.storage.mongo.pl
# once (21µs+329µs) by Class::MOP::Class:::around at line 48 of MongoDB/Connection.pm
# once (9µs+259µs) by main::RUNTIME at line 12 of mentat.storage.mongo.pl | ||||
23 | 3 | 2µs | my $class = shift; | ||
24 | 3 | 11µs | 3 | 2µs | my $real_class = Scalar::Util::blessed($class) || $class; # spent 2µs making 3 calls to Scalar::Util::blessed, avg 633ns/call |
25 | |||||
26 | 3 | 13µs | 3 | 13µs | my $params = $real_class->BUILDARGS(@_); # spent 13µs making 3 calls to Moose::Object::BUILDARGS, avg 4µs/call |
27 | |||||
28 | 3 | 28µs | 6 | 996µs | return Class::MOP::Class->initialize($real_class)->new_object($params); # spent 973µs making 3 calls to Moose::Meta::Class::new_object, avg 324µs/call
# spent 23µs making 3 calls to Class::MOP::Class::initialize, avg 8µs/call |
29 | } | ||||
30 | |||||
31 | # spent 13µs within Moose::Object::BUILDARGS which was called 3 times, avg 4µs/call:
# 3 times (13µs+0s) by Moose::Object::new at line 26, avg 4µs/call | ||||
32 | 3 | 1µs | my $class = shift; | ||
33 | 3 | 4µs | 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 | 3 | 10µs | return {@_}; | ||
49 | } | ||||
50 | } | ||||
51 | |||||
52 | # spent 15µs (11+5) within Moose::Object::BUILDALL which was called 3 times, avg 5µs/call:
# 3 times (11µs+5µs) by Moose::Meta::Class::new_object at line 288 of Moose/Meta/Class.pm, avg 5µs/call | ||||
53 | # NOTE: we ask Perl if we even | ||||
54 | # need to do this first, to avoid | ||||
55 | # extra meta level calls | ||||
56 | 3 | 17µs | 3 | 5µs | return unless $_[0]->can('BUILD'); # spent 5µs making 3 calls to UNIVERSAL::can, avg 2µs/call |
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 | # spent 34µs (24+10) within Moose::Object::DEMOLISHALL which was called 5 times, avg 7µs/call:
# 5 times (24µs+10µs) by Moose::Object::try {...} at line 98, avg 7µs/call | ||||
64 | 5 | 2µs | my $self = shift; | ||
65 | 5 | 3µs | 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 | 5 | 31µs | 5 | 10µs | return unless $self->can('DEMOLISH'); # spent 10µs making 5 calls to UNIVERSAL::can, avg 2µs/call |
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 | 166µs | 2 | 47µs | # spent 31µs (14+16) within Moose::Object::BEGIN@85 which was called:
# once (14µs+16µs) by Moose::BEGIN@33 at line 85 # spent 31µs making 1 call to Moose::Object::BEGIN@85
# spent 16µ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 | # spent 297µs (86+211) within Moose::Object::DESTROY which was called 5 times, avg 59µs/call:
# 2 times (39µs+82µs) by Mentat::Storage::Mongo::_unbless at line 916 of Mentat/Storage/Mongo.pm, avg 60µs/call
# 2 times (22µs+58µs) by main::NULL at line 0 of mentat.storage.mongo.pl, avg 40µs/call
# once (26µs+71µs) by Mentat::Storage::Mongo::disconnect at line 553 of Mentat/Storage/Mongo.pm | ||||
93 | 5 | 2µs | my $self = shift; | ||
94 | |||||
95 | 5 | 10µs | local $?; | ||
96 | |||||
97 | Try::Tiny::try { | ||||
98 | 5 | 28µs | 10 | 46µs | $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction); # spent 34µs making 5 calls to Moose::Object::DEMOLISHALL, avg 7µs/call
# spent 12µs making 5 calls to Devel::GlobalDestruction::in_global_destruction, avg 2µs/call |
99 | } | ||||
100 | Try::Tiny::catch { | ||||
101 | die $_; | ||||
102 | 5 | 57µs | 10 | 211µs | }; # spent 189µs making 5 calls to Try::Tiny::try, avg 38µs/call
# spent 22µs making 5 calls to Try::Tiny::catch, avg 4µs/call |
103 | |||||
104 | 5 | 17µs | return; | ||
105 | } | ||||
106 | |||||
107 | # support for UNIVERSAL::DOES ... | ||||
108 | # spent 64µs (62+1) within Moose::Object::BEGIN@108 which was called:
# once (62µs+1µs) by Moose::BEGIN@33 at line 115 | ||||
109 | 1 | 10µs | 1 | 1µs | my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa"; # spent 1µs making 1 call to UNIVERSAL::can |
110 | 1 | 53µ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 | 111µs | 1 | 64µs | } # spent 64µ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 | sub does { | ||||
120 | my ($self, $role_name) = @_; | ||||
121 | my $class = Scalar::Util::blessed($self) || $self; | ||||
122 | my $meta = Class::MOP::Class->initialize($class); | ||||
123 | (defined $role_name) | ||||
124 | || $meta->throw_error("You must supply a role name to does()"); | ||||
125 | return 1 if $meta->can('does_role') && $meta->does_role($role_name); | ||||
126 | return 0; | ||||
127 | } | ||||
128 | |||||
129 | sub dump { | ||||
130 | my $self = shift; | ||||
131 | require Data::Dumper; | ||||
132 | local $Data::Dumper::Maxdepth = shift if @_; | ||||
133 | Data::Dumper::Dumper $self; | ||||
134 | } | ||||
135 | |||||
136 | 1 | 3µs | 1; | ||
137 | |||||
138 | # ABSTRACT: The base object for Moose | ||||
139 | |||||
140 | __END__ |