Filename | /usr/local/lib/perl/5.14.2/Moose/Object.pm |
Statements | Executed 90 statements in 1.28ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 207µs | 233µs | BEGIN@19 | Moose::Object::
5 | 3 | 2 | 80µs | 282µs | DESTROY | Moose::Object::
1 | 1 | 1 | 59µs | 60µs | BEGIN@108 | Moose::Object::
3 | 3 | 2 | 46µs | 934µs | new | Moose::Object::
5 | 1 | 1 | 24µs | 33µs | DEMOLISHALL | Moose::Object::
1 | 1 | 1 | 15µs | 15µs | BEGIN@13 | Moose::Object::
1 | 1 | 1 | 13µs | 1.98ms | BEGIN@20 | Moose::Object::
1 | 1 | 1 | 12µs | 27µs | BEGIN@85 | Moose::Object::
3 | 1 | 1 | 11µs | 11µs | BUILDARGS | Moose::Object::
3 | 1 | 1 | 9µs | 19µs | BUILDALL | Moose::Object::
1 | 1 | 1 | 8µs | 11µs | BEGIN@10 | Moose::Object::
1 | 1 | 1 | 8µs | 15µs | BEGIN@11 | Moose::Object::
1 | 1 | 1 | 8µs | 8µs | BEGIN@3 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@16 | Moose::Object::
1 | 1 | 1 | 3µs | 3µs | BEGIN@14 | 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 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 | 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 | 29µs | 2 | 21µs | # spent 15µs (8+7) within Moose::Object::BEGIN@11 which was called:
# once (8µs+7µs) by Moose::BEGIN@33 at line 11 # spent 15µs making 1 call to Moose::Object::BEGIN@11
# spent 7µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 31µs | 1 | 15µs | # spent 15µs within Moose::Object::BEGIN@13 which was called:
# once (15µs+0s) by Moose::BEGIN@33 at line 13 # spent 15µ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 | 17µ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 | 228µs | 2 | 237µs | # spent 233µs (207+26) within Moose::Object::BEGIN@19 which was called:
# once (207µs+26µs) by Moose::BEGIN@33 at line 19 # spent 233µs making 1 call to Moose::Object::BEGIN@19
# spent 4µs making 1 call to if::import |
20 | 2 | 311µs | 2 | 1.98ms | # spent 1.98ms (13µs+1.96) within Moose::Object::BEGIN@20 which was called:
# once (13µs+1.96ms) by Moose::BEGIN@33 at line 20 # spent 1.98ms making 1 call to Moose::Object::BEGIN@20
# spent 2µs making 1 call to if::import |
21 | |||||
22 | # spent 934µs (46+888) within Moose::Object::new which was called 3 times, avg 311µs/call:
# once (20µs+358µs) by main::RUNTIME at line 11 of mentat.storage.mongo.pl
# once (16µs+275µs) by Class::MOP::Class:::around at line 48 of MongoDB/Connection.pm
# once (9µs+255µs) by main::RUNTIME at line 12 of mentat.storage.mongo.pl | ||||
23 | 3 | 1µs | my $class = shift; | ||
24 | 3 | 9µs | 3 | 2µs | my $real_class = Scalar::Util::blessed($class) || $class; # spent 2µs making 3 calls to Scalar::Util::blessed, avg 567ns/call |
25 | |||||
26 | 3 | 11µs | 3 | 11µs | my $params = $real_class->BUILDARGS(@_); # spent 11µs making 3 calls to Moose::Object::BUILDARGS, avg 4µs/call |
27 | |||||
28 | 3 | 22µs | 6 | 876µs | return Class::MOP::Class->initialize($real_class)->new_object($params); # spent 858µs making 3 calls to Moose::Meta::Class::new_object, avg 286µs/call
# spent 18µs making 3 calls to Class::MOP::Class::initialize, avg 6µs/call |
29 | } | ||||
30 | |||||
31 | # spent 11µs within Moose::Object::BUILDARGS which was called 3 times, avg 4µs/call:
# 3 times (11µs+0s) by Moose::Object::new at line 26, avg 4µs/call | ||||
32 | 3 | 1µs | my $class = shift; | ||
33 | 3 | 3µ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 | 9µs | return {@_}; | ||
49 | } | ||||
50 | } | ||||
51 | |||||
52 | # spent 19µs (9+9) within Moose::Object::BUILDALL which was called 3 times, avg 6µs/call:
# 3 times (9µs+9µs) by Moose::Meta::Class::new_object at line 288 of Moose/Meta/Class.pm, avg 6µ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 | 20µs | 3 | 9µs | return unless $_[0]->can('BUILD'); # spent 9µs making 3 calls to UNIVERSAL::can, avg 3µ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 33µs (24+9) within Moose::Object::DEMOLISHALL which was called 5 times, avg 7µs/call:
# 5 times (24µs+9µ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 | 9µs | return unless $self->can('DEMOLISH'); # spent 9µ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 | 156µs | 2 | 41µs | # spent 27µs (12+14) within Moose::Object::BEGIN@85 which was called:
# once (12µs+14µs) by Moose::BEGIN@33 at line 85 # spent 27µs making 1 call to Moose::Object::BEGIN@85
# spent 14µ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 282µs (80+202) within Moose::Object::DESTROY which was called 5 times, avg 56µs/call:
# 2 times (33µs+77µs) by Mentat::Storage::Mongo::_unbless at line 916 of Mentat/Storage/Mongo.pm, avg 55µs/call
# 2 times (21µs+56µs) by main::NULL at line 0 of mentat.storage.mongo.pl, avg 39µs/call
# once (25µs+69µs) by Mentat::Storage::Mongo::disconnect at line 553 of Mentat/Storage/Mongo.pm | ||||
93 | 5 | 1µs | my $self = shift; | ||
94 | |||||
95 | 5 | 9µs | local $?; | ||
96 | |||||
97 | Try::Tiny::try { | ||||
98 | 5 | 25µs | 10 | 43µs | $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction); # spent 33µs making 5 calls to Moose::Object::DEMOLISHALL, avg 7µs/call
# spent 10µs making 5 calls to Devel::GlobalDestruction::in_global_destruction, avg 2µs/call |
99 | } | ||||
100 | Try::Tiny::catch { | ||||
101 | die $_; | ||||
102 | 5 | 52µs | 10 | 202µs | }; # spent 181µs making 5 calls to Try::Tiny::try, avg 36µs/call
# spent 21µs making 5 calls to Try::Tiny::catch, avg 4µs/call |
103 | |||||
104 | 5 | 15µs | return; | ||
105 | } | ||||
106 | |||||
107 | # support for UNIVERSAL::DOES ... | ||||
108 | # spent 60µs (59+1) within Moose::Object::BEGIN@108 which was called:
# once (59µ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 | 50µ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 | 110µs | 1 | 60µs | } # spent 60µ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__ |