Profile of Moose/Object.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:50 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Object.pm
Statements | Executed 99 statements in 1.63ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 208µs | 248µs | Moose::Object::::BEGIN@19Moose::Object::BEGIN@19
3 | 1 | 1 | 172µs | 1.40ms | Moose::Object::::doesMoose::Object::does
3 | 1 | 1 | 108µs | 434µs | Moose::Object::::DESTROYMoose::Object::DESTROY
3 | 1 | 1 | 98µs | 186µs | Moose::Object::::__ANON__[:99]Moose::Object::__ANON__[:99]
1 | 1 | 1 | 56µs | 57µs | Moose::Object::::BEGIN@108Moose::Object::BEGIN@108
3 | 3 | 3 | 52µs | 4.13ms | Moose::Object::::newMoose::Object::new (recurses: max depth 1, inclusive time 237µs)
1 | 1 | 1 | 51µs | 67µs | Moose::Object::::BEGIN@85Moose::Object::BEGIN@85
3 | 1 | 1 | 39µs | 73µs | Moose::Object::::DEMOLISHALLMoose::Object::DEMOLISHALL
1 | 1 | 1 | 14µs | 2.46ms | Moose::Object::::BEGIN@20Moose::Object::BEGIN@20
3 | 1 | 1 | 11µs | 11µs | Moose::Object::::BUILDARGSMoose::Object::BUILDARGS
1 | 1 | 1 | 10µs | 10µs | Moose::Object::::BEGIN@3Moose::Object::BEGIN@3
3 | 1 | 1 | 9µs | 27µs | Moose::Object::::BUILDALLMoose::Object::BUILDALL
1 | 1 | 1 | 9µs | 14µs | Moose::Object::::BEGIN@10Moose::Object::BEGIN@10
1 | 1 | 1 | 8µs | 24µs | Moose::Object::::BEGIN@11Moose::Object::BEGIN@11
1 | 1 | 1 | 6µs | 6µs | Moose::Object::::BEGIN@15Moose::Object::BEGIN@15
1 | 1 | 1 | 4µs | 4µs | Moose::Object::::BEGIN@16Moose::Object::BEGIN@16
1 | 1 | 1 | 3µs | 3µs | Moose::Object::::BEGIN@14Moose::Object::BEGIN@14
1 | 1 | 1 | 3µs | 3µs | Moose::Object::::BEGIN@13Moose::Object::BEGIN@13
1 | 1 | 1 | 3µs | 3µs | Moose::Object::::BEGIN@17Moose::Object::BEGIN@17
0 | 0 | 0 | 0s | 0s | Moose::Object::::__ANON__[:102]Moose::Object::__ANON__[:102]
0 | 0 | 0 | 0s | 0s | Moose::Object::::dumpMoose::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 |  |  |  |  |
2 |  |  |  |  | package Moose::Object;
3 |  |  |  |  | # spent 10µs within Moose::Object::BEGIN@3 which was called: # once (10µs+0s) by Moose::BEGIN@34 at line 5 BEGIN {
4 | 1 | 5µs |  |  | $Moose::Object::AUTHORITY = 'cpan:STEVAN';
5 | 1 | 24µs | 1 | 10µs | } # spent 10µs making 1 call to Moose::Object::BEGIN@3
6 |  |  |  |  | {
7 | 2 | 1µs |  |  | $Moose::Object::VERSION = '2.0602';
8 |  |  |  |  | }
9 |  |  |  |  |
10 | 3 | 19µs | 2 | 19µs | # spent 14µs (9+5) within Moose::Object::BEGIN@10 which was called: # once (9µs+5µs) by Moose::BEGIN@34 at line 10 use strict; # spent 14µs making 1 call to Moose::Object::BEGIN@10 # spent 5µs making 1 call to strict::import
11 | 3 | 18µs | 2 | 40µs | # spent 24µs (8+16) within Moose::Object::BEGIN@11 which was called: # once (8µs+16µs) by Moose::BEGIN@34 at line 11 use warnings; # spent 24µs making 1 call to Moose::Object::BEGIN@11 # spent 16µs making 1 call to warnings::import
12 |  |  |  |  |
13 | 3 | 15µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@13 which was called: # once (3µs+0s) by Moose::BEGIN@34 at line 13 use Carp (); # spent 3µs making 1 call to Moose::Object::BEGIN@13
14 | 3 | 17µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@14 which was called: # once (3µs+0s) by Moose::BEGIN@34 at line 14 use Devel::GlobalDestruction (); # spent 3µs making 1 call to Moose::Object::BEGIN@14
15 | 3 | 14µs | 1 | 6µs | # spent 6µs within Moose::Object::BEGIN@15 which was called: # once (6µs+0s) by Moose::BEGIN@34 at line 15 use MRO::Compat (); # spent 6µs making 1 call to Moose::Object::BEGIN@15
16 | 3 | 18µs | 1 | 4µs | # spent 4µs within Moose::Object::BEGIN@16 which was called: # once (4µs+0s) by Moose::BEGIN@34 at line 16 use Scalar::Util (); # spent 4µs making 1 call to Moose::Object::BEGIN@16
17 | 3 | 27µs | 1 | 3µs | # spent 3µs within Moose::Object::BEGIN@17 which was called: # once (3µs+0s) by Moose::BEGIN@34 at line 17 use Try::Tiny (); # spent 3µs making 1 call to Moose::Object::BEGIN@17
18 |  |  |  |  |
19 | 3 | 223µs | 2 | 252µs | # spent 248µs (208+40) within Moose::Object::BEGIN@19 which was called: # once (208µs+40µs) by Moose::BEGIN@34 at line 19 use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class'; # spent 248µs making 1 call to Moose::Object::BEGIN@19 # spent 4µs making 1 call to if::import
20 | 3 | 326µs | 2 | 2.46ms | # spent 2.46ms (14µs+2.45) within Moose::Object::BEGIN@20 which was called: # once (14µs+2.45ms) by Moose::BEGIN@34 at line 20 use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class'; # spent 2.46ms making 1 call to Moose::Object::BEGIN@20 # spent 2µs making 1 call to if::import
21 |  |  |  |  |
22 |  |  |  |  | # spent 4.13ms (52µs+4.07) within Moose::Object::new which was called 3 times, avg 1.38ms/call: # once (22µs+3.26ms) by MooseX::Traits::new_with_traits at line 52 of MooseX/Traits.pm # once (17µs+823µs) by main::RUNTIME at line 46 of xt/tapper-mcp-scheduler-with-db-longrun.t # once (13µs+-13µs) by Tapper::MCP::Scheduler::Controller::__ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:14] at line 14 of lib/Tapper/MCP/Scheduler/Controller.pm sub new {
23 | 12 | 58µs |  |  | my $class = shift;
24 |  |  | 3 | 2µs | my $real_class = Scalar::Util::blessed($class) || $class; # spent 2µs making 3 calls to Scalar::Util::blessed, avg 800ns/call
25 |  |  |  |  |
26 |  |  | 3 | 11µs | my $params = $real_class->BUILDARGS(@_); # spent 11µs making 3 calls to Moose::Object::BUILDARGS, avg 4µs/call
27 |  |  |  |  |
28 |  |  | 6 | 4.08ms | return Class::MOP::Class->initialize($real_class)->new_object($params); # spent 4.28ms making 3 calls to Moose::Meta::Class::new_object, avg 1.43ms/call, recursion: max depth 1, sum of overlapping time 216µs # spent 15µs making 3 calls to Class::MOP::Class::initialize, avg 5µ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 sub BUILDARGS {
32 | 6 | 5µs |  |  | my $class = shift;
33 | 3 | 9µ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 |  |  |  |  | return {@_};
49 |  |  |  |  | }
50 |  |  |  |  | }
51 |  |  |  |  |
52 |  |  |  |  | # spent 27µs (9+18) within Moose::Object::BUILDALL which was called 3 times, avg 9µs/call: # 3 times (9µs+18µs) by Moose::Meta::Class::new_object at line 278 of Moose/Meta/Class.pm, avg 9µs/call sub BUILDALL {
53 |  |  |  |  | # NOTE: we ask Perl if we even
54 |  |  |  |  | # need to do this first, to avoid
55 |  |  |  |  | # extra meta level calls
56 | 3 | 30µs | 3 | 18µs | return unless $_[0]->can('BUILD'); # spent 18µs making 3 calls to UNIVERSAL::can, avg 6µ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 73µs (39+35) within Moose::Object::DEMOLISHALL which was called 3 times, avg 24µs/call: # 3 times (39µs+35µs) by Moose::Object::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Object.pm:99] at line 98, avg 24µs/call sub DEMOLISHALL {
64 | 9 | 87µs |  |  | 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 |  |  | 3 | 35µs | return unless $self->can('DEMOLISH'); # spent 35µs making 3 calls to UNIVERSAL::can, avg 12µ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 | 3 | 145µs | 2 | 83µs | # spent 67µs (51+16) within Moose::Object::BEGIN@85 which was called: # once (51µs+16µs) by Moose::BEGIN@34 at line 85 no strict 'refs'; # spent 67µ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 434µs (108+326) within Moose::Object::DESTROY which was called 3 times, avg 145µs/call: # 3 times (108µs+326µs) by main::NULL at line 0 of xt/tapper-mcp-scheduler-with-db-longrun.t, avg 145µs/call sub DESTROY {
93 | 12 | 91µs |  |  | my $self = shift;
94 |  |  |  |  |
95 |  |  |  |  | local $?;
96 |  |  |  |  |
97 |  |  |  |  | # spent 186µs (98+88) within Moose::Object::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Object.pm:99] which was called 3 times, avg 62µs/call: # 3 times (98µs+88µs) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 62µs/call Try::Tiny::try {
98 | 3 | 112µs | 6 | 88µs | $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction); # spent 73µs making 3 calls to Moose::Object::DEMOLISHALL, avg 24µs/call # spent 15µs making 3 calls to Devel::GlobalDestruction::in_global_destruction, avg 5µs/call
99 |  |  |  |  | }
100 |  |  |  |  | Try::Tiny::catch {
101 |  |  |  |  | die $_;
102 |  |  | 6 | 326µs | }; # spent 296µs making 3 calls to Try::Tiny::try, avg 99µs/call # spent 30µs making 3 calls to Try::Tiny::catch, avg 10µs/call
103 |  |  |  |  |
104 |  |  |  |  | return;
105 |  |  |  |  | }
106 |  |  |  |  |
107 |  |  |  |  | # support for UNIVERSAL::DOES ...
108 |  |  |  |  | # spent 57µs (56+2) within Moose::Object::BEGIN@108 which was called: # once (56µs+2µs) by Moose::BEGIN@34 at line 115 BEGIN {
109 | 2 | 58µs | 1 | 2µs | my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa"; # spent 2µs making 1 call to UNIVERSAL::can
110 |  |  |  |  | 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 | 146µs | 1 | 57µs | } # spent 57µs making 1 call to Moose::Object::BEGIN@108
116 |  |  |  |  |
117 |  |  |  |  | # new does() methods will be created
118 |  |  |  |  | # as appropiate see Moose::Meta::Role
119 |  |  |  |  | # spent 1.40ms (172µs+1.22) within Moose::Object::does which was called 3 times, avg 466µs/call: # 3 times (172µs+1.22ms) by MooseX::Traits::Util::check_class at line 17 of MooseX/Traits/Util.pm, avg 466µs/call sub does {
120 | 15 | 178µs |  |  | my ($self, $role_name) = @_;
121 |  |  | 3 | 4µs | my $class = Scalar::Util::blessed($self) || $self; # spent 4µs making 3 calls to Scalar::Util::blessed, avg 2µs/call
122 |  |  | 3 | 65µs | my $meta = Class::MOP::Class->initialize($class); # spent 65µs making 3 calls to Class::MOP::Class::initialize, avg 22µs/call
123 |  |  |  |  | (defined $role_name)
124 |  |  |  |  | || $meta->throw_error("You must supply a role name to does()");
125 |  |  | 6 | 1.16ms | return 1 if $meta->can('does_role') && $meta->does_role($role_name); # spent 1.15ms making 3 calls to Moose::Meta::Class::does_role, avg 382µs/call # spent 10µs making 3 calls to UNIVERSAL::can, avg 3µs/call
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 |  |  |  |  |
- - |  |  |  |  |
142 |  |  |  |  | =pod
143 |  |  |  |  |
144 |  |  |  |  | =head1 NAME
145 |  |  |  |  |
146 |  |  |  |  | Moose::Object - The base object for Moose
147 |  |  |  |  |
148 |  |  |  |  | =head1 VERSION
149 |  |  |  |  |
150 |  |  |  |  | version 2.0602
151 |  |  |  |  |
152 |  |  |  |  | =head1 DESCRIPTION
153 |  |  |  |  |
154 |  |  |  |  | This class is the default base class for all Moose-using classes. When
155 |  |  |  |  | you C<use Moose> in this class, your class will inherit from this
156 |  |  |  |  | class.
157 |  |  |  |  |
158 |  |  |  |  | It provides a default constructor and destructor, which run all of the
159 |  |  |  |  | C<BUILD> and C<DEMOLISH> methods in the inheritance hierarchy,
160 |  |  |  |  | respectively.
161 |  |  |  |  |
162 |  |  |  |  | You don't actually I<need> to inherit from this in order to use Moose,
163 |  |  |  |  | but it makes it easier to take advantage of all of Moose's features.
164 |  |  |  |  |
165 |  |  |  |  | =head1 METHODS
166 |  |  |  |  |
167 |  |  |  |  | =over 4
168 |  |  |  |  |
169 |  |  |  |  | =item B<< Moose::Object->new(%params|$params) >>
170 |  |  |  |  |
171 |  |  |  |  | This method calls C<< $class->BUILDARGS(@_) >>, and then creates a new
172 |  |  |  |  | instance of the appropriate class. Once the instance is created, it
173 |  |  |  |  | calls C<< $instance->BUILD($params) >> for each C<BUILD> method in the
174 |  |  |  |  | inheritance hierarchy.
175 |  |  |  |  |
176 |  |  |  |  | =item B<< Moose::Object->BUILDARGS(%params|$params) >>
177 |  |  |  |  |
178 |  |  |  |  | The default implementation of this method accepts a hash or hash
179 |  |  |  |  | reference of named parameters. If it receives a single argument that
180 |  |  |  |  | I<isn't> a hash reference it throws an error.
181 |  |  |  |  |
182 |  |  |  |  | You can override this method in your class to handle other types of
183 |  |  |  |  | options passed to the constructor.
184 |  |  |  |  |
185 |  |  |  |  | This method should always return a hash reference of named options.
186 |  |  |  |  |
187 |  |  |  |  | =item B<< $object->does($role_name) >>
188 |  |  |  |  |
189 |  |  |  |  | This returns true if the object does the given role.
190 |  |  |  |  |
191 |  |  |  |  | =item B<< $object->DOES($class_or_role_name) >>
192 |  |  |  |  |
193 |  |  |  |  | This is a a Moose role-aware implementation of L<UNIVERSAL/DOES>.
194 |  |  |  |  |
195 |  |  |  |  | This is effectively the same as writing:
196 |  |  |  |  |
197 |  |  |  |  | $object->does($name) || $object->isa($name)
198 |  |  |  |  |
199 |  |  |  |  | This method will work with Perl 5.8, which did not implement
200 |  |  |  |  | C<UNIVERSAL::DOES>.
201 |  |  |  |  |
202 |  |  |  |  | =item B<< $object->dump($maxdepth) >>
203 |  |  |  |  |
204 |  |  |  |  | This is a handy utility for C<Data::Dumper>ing an object. By default,
205 |  |  |  |  | the maximum depth is 1, to avoid making a mess.
206 |  |  |  |  |
207 |  |  |  |  | =item B<< $object->DESTROY >>
208 |  |  |  |  |
209 |  |  |  |  | A default destructor is provided, which calls
210 |  |  |  |  | C<< $instance->DEMOLISH($in_global_destruction) >> for each C<DEMOLISH>
211 |  |  |  |  | method in the inheritance hierarchy.
212 |  |  |  |  |
213 |  |  |  |  | =back
214 |  |  |  |  |
215 |  |  |  |  | =head1 BUGS
216 |  |  |  |  |
217 |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs.
218 |  |  |  |  |
219 |  |  |  |  | =head1 AUTHOR
220 |  |  |  |  |
221 |  |  |  |  | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
222 |  |  |  |  |
223 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
224 |  |  |  |  |
225 |  |  |  |  | This software is copyright (c) 2012 by Infinity Interactive, Inc..
226 |  |  |  |  |
227 |  |  |  |  | This is free software; you can redistribute it and/or modify it under
228 |  |  |  |  | the same terms as the Perl 5 programming language system itself.
229 |  |  |  |  |
230 |  |  |  |  | =cut
231 |  |  |  |  |
232 |  |  |  |  |
233 |  |  |  |  | __END__