← 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:23:38 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Role.pm
StatementsExecuted 126 statements in 1.25ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
411207µs5.88msMoose::Role::::init_metaMoose::Role::init_meta
433104µs1.42msMoose::Role::::hasMoose::Role::has
43335µs549µsMoose::Role::::requiresMoose::Role::requires
11122µs22µsMoose::Role::::BEGIN@21Moose::Role::BEGIN@21
11112µs49µsMoose::Role::::BEGIN@11Moose::Role::BEGIN@11
11111µs180µsMoose::Role::::BEGIN@15Moose::Role::BEGIN@15
11110µs1.42msMoose::Role::::BEGIN@22Moose::Role::BEGIN@22
11110µs18µsMoose::Role::::BEGIN@9Moose::Role::BEGIN@9
11110µs29µsMoose::Role::::BEGIN@13Moose::Role::BEGIN@13
1119µs31µsMoose::Role::::BEGIN@20Moose::Role::BEGIN@20
1119µs9µsMoose::Role::::BEGIN@2Moose::Role::BEGIN@2
1118µs28µsMoose::Role::::BEGIN@12Moose::Role::BEGIN@12
1116µs8µsMoose::Role::::BEGIN@8Moose::Role::BEGIN@8
1113µs3µsMoose::Role::::BEGIN@17Moose::Role::BEGIN@17
1113µs3µsMoose::Role::::BEGIN@18Moose::Role::BEGIN@18
0000s0sMoose::Role::::_add_method_modifierMoose::Role::_add_method_modifier
0000s0sMoose::Role::::afterMoose::Role::after
0000s0sMoose::Role::::aroundMoose::Role::around
0000s0sMoose::Role::::augmentMoose::Role::augment
0000s0sMoose::Role::::beforeMoose::Role::before
0000s0sMoose::Role::::excludesMoose::Role::excludes
0000s0sMoose::Role::::extendsMoose::Role::extends
0000s0sMoose::Role::::innerMoose::Role::inner
0000s0sMoose::Role::::overrideMoose::Role::override
0000s0sMoose::Role::::superMoose::Role::super
0000s0sMoose::Role::::withMoose::Role::with
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Role;
2
# spent 9µs within Moose::Role::BEGIN@2 which was called: # once (9µs+0s) by Any::Moose::_install_module at line 4
BEGIN {
314µs $Moose::Role::AUTHORITY = 'cpan:STEVAN';
4121µs19µs}
# spent 9µs making 1 call to Moose::Role::BEGIN@2
5{
621µs $Moose::Role::VERSION = '2.0602';
7}
8320µs210µs
# spent 8µs (6+2) within Moose::Role::BEGIN@8 which was called: # once (6µs+2µs) by Any::Moose::_install_module at line 8
use strict;
# spent 8µs making 1 call to Moose::Role::BEGIN@8 # spent 2µs making 1 call to strict::import
9318µs226µs
# spent 18µs (10+8) within Moose::Role::BEGIN@9 which was called: # once (10µs+8µs) by Any::Moose::_install_module at line 9
use warnings;
# spent 18µs making 1 call to Moose::Role::BEGIN@9 # spent 8µs making 1 call to warnings::import
10
11324µs287µs
# spent 49µs (12+38) within Moose::Role::BEGIN@11 which was called: # once (12µs+38µs) by Any::Moose::_install_module at line 11
use Scalar::Util 'blessed';
# spent 49µs making 1 call to Moose::Role::BEGIN@11 # spent 38µs making 1 call to Exporter::import
12319µs248µs
# spent 28µs (8+20) within Moose::Role::BEGIN@12 which was called: # once (8µs+20µs) by Any::Moose::_install_module at line 12
use Carp 'croak';
# spent 28µs making 1 call to Moose::Role::BEGIN@12 # spent 20µs making 1 call to Exporter::import
13320µs249µs
# spent 29µs (10+20) within Moose::Role::BEGIN@13 which was called: # once (10µs+20µs) by Any::Moose::_install_module at line 13
use Class::Load 'is_class_loaded';
# spent 29µs making 1 call to Moose::Role::BEGIN@13 # spent 20µs making 1 call to Exporter::import
14
15323µs2349µs
# spent 180µs (11+169) within Moose::Role::BEGIN@15 which was called: # once (11µs+169µs) by Any::Moose::_install_module at line 15
use Sub::Exporter;
# spent 180µs making 1 call to Moose::Role::BEGIN@15 # spent 169µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
16
17314µs13µs
# spent 3µs within Moose::Role::BEGIN@17 which was called: # once (3µs+0s) by Any::Moose::_install_module at line 17
use Moose ();
# spent 3µs making 1 call to Moose::Role::BEGIN@17
18315µs13µs
# spent 3µs within Moose::Role::BEGIN@18 which was called: # once (3µs+0s) by Any::Moose::_install_module at line 18
use Moose::Util ();
# spent 3µs making 1 call to Moose::Role::BEGIN@18
19
20321µs252µs
# spent 31µs (9+21) within Moose::Role::BEGIN@20 which was called: # once (9µs+21µs) by Any::Moose::_install_module at line 20
use Moose::Exporter;
# spent 31µs making 1 call to Moose::Role::BEGIN@20 # spent 21µs making 1 call to Moose::Exporter::import
21334µs122µs
# spent 22µs within Moose::Role::BEGIN@21 which was called: # once (22µs+0s) by Any::Moose::_install_module at line 21
use Moose::Meta::Role;
# spent 22µs making 1 call to Moose::Role::BEGIN@21
223692µs22.84ms
# spent 1.42ms (10µs+1.41) within Moose::Role::BEGIN@22 which was called: # once (10µs+1.41ms) by Any::Moose::_install_module at line 22
use Moose::Util::TypeConstraints;
# spent 1.42ms making 1 call to Moose::Role::BEGIN@22 # spent 1.41ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:492]
23
24sub extends {
25 croak "Roles do not support 'extends' (you can use 'with' to specialize a role)";
26}
27
28sub with {
29 Moose::Util::apply_all_roles( shift, @_ );
30}
31
32
# spent 549µs (35+514) within Moose::Role::requires which was called 4 times, avg 137µs/call: # 2 times (14µs+238µs) by Moose::Role::requires at line 382 of Moose/Exporter.pm, avg 126µs/call # once (12µs+206µs) by Module::Runtime::require_module at line 9 of lib/Tapper/MCP/Net/TAP.pm # once (9µs+69µs) by main::BEGIN@1.15 at line 7 of lib/Tapper/MCP/Scheduler/Algorithm/WFQ.pm
sub requires {
3322µs my $meta = shift;
3421µs croak "Must specify at least one method" unless @_;
35213µs2238µs $meta->add_required_methods(@_);
# spent 238µs making 2 calls to Moose::Meta::Role::add_required_methods, avg 119µs/call
36}
37
38sub excludes {
39 my $meta = shift;
40 croak "Must specify at least one role" unless @_;
41 $meta->add_excluded_roles(@_);
42}
43
44
# spent 1.42ms (104µs+1.32) within Moose::Role::has which was called 4 times, avg 356µs/call: # 2 times (72µs+597µs) by Moose::Role::has at line 382 of Moose/Exporter.pm, avg 334µs/call # once (21µs+471µs) by Module::Runtime::require_module at line 14 of MooseX/Traits.pm # once (12µs+251µs) by Module::Runtime::require_module at line 14 of MooseX/Log/Log4perl.pm
sub has {
4522µs my $meta = shift;
4622µs my $name = shift;
4722µs croak 'Usage: has \'name\' => ( key => value, ... )' if @_ == 1;
48225µs239µs my %options = ( definition_context => Moose::Util::_caller_info(), @_ );
# spent 39µs making 2 calls to Moose::Util::_caller_info, avg 19µs/call
4924µs my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ];
50434µs2558µs $meta->add_attribute( $_, %options ) for @$attrs;
# spent 558µs making 2 calls to Moose::Meta::Role::add_attribute, avg 279µs/call
51}
52
53sub _add_method_modifier {
54 my $type = shift;
55 my $meta = shift;
56
57 if ( ref($_[0]) eq 'Regexp' ) {
58 croak "Roles do not currently support regex "
59 . " references for $type method modifiers";
60 }
61
62 Moose::Util::add_method_modifier($meta, $type, \@_);
63}
64
65sub before { _add_method_modifier('before', @_) }
66
67sub after { _add_method_modifier('after', @_) }
68
69sub around { _add_method_modifier('around', @_) }
70
71# see Moose.pm for discussion
72sub super {
73 return unless $Moose::SUPER_BODY;
74 $Moose::SUPER_BODY->(@Moose::SUPER_ARGS);
75}
76
77sub override {
78 my $meta = shift;
79 my ( $name, $code ) = @_;
80 $meta->add_override_method_modifier( $name, $code );
81}
82
83sub inner {
84 croak "Roles cannot support 'inner'";
85}
86
87sub augment {
88 croak "Roles cannot support 'augment'";
89}
90
9117µs1922µsMoose::Exporter->setup_import_methods(
# spent 922µs making 1 call to Moose::Exporter::setup_import_methods
92 with_meta => [
93 qw( with requires excludes has before after around override )
94 ],
95 as_is => [
96 qw( extends super inner augment ),
97 \&Carp::confess,
98 \&Scalar::Util::blessed,
99 ],
100);
101
102
# spent 5.88ms (207µs+5.67) within Moose::Role::init_meta which was called 4 times, avg 1.47ms/call: # 4 times (207µs+5.67ms) by Moose::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm:492] at line 447 of Moose/Exporter.pm, avg 1.47ms/call
sub init_meta {
10342µs shift;
104414µs my %args = @_;
105
10643µs my $role = $args{for_class};
107
10841µs unless ($role) {
109 require Moose;
110 Moose->throw_error("Cannot call init_meta without specifying a for_class");
111 }
112
11343µs my $metaclass = $args{metaclass} || "Moose::Meta::Role";
11443µs my $meta_name = exists $args{meta_name} ? $args{meta_name} : 'meta';
115
116431µs418µs Moose->throw_error("The Metaclass $metaclass must be loaded. (Perhaps you forgot to 'use $metaclass'?)")
# spent 18µs making 4 calls to Class::Load::XS::is_class_loaded, avg 4µs/call
117 unless is_class_loaded($metaclass);
118
119446µs47µs Moose->throw_error("The Metaclass $metaclass must be a subclass of Moose::Meta::Role.")
# spent 7µs making 4 calls to UNIVERSAL::isa, avg 2µs/call
120 unless $metaclass->isa('Moose::Meta::Role');
121
122 # make a subtype for each Moose role
123420µs82.49ms role_type $role unless find_type_constraint($role);
# spent 2.39ms making 4 calls to Moose::Util::TypeConstraints::role_type, avg 597µs/call # spent 100µs making 4 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 25µs/call
124
12541µs my $meta;
126413µs413µs if ( $meta = Class::MOP::get_metaclass_by_name($role) ) {
# spent 13µs making 4 calls to Class::MOP::get_metaclass_by_name, avg 3µs/call
127 unless ( $meta->isa("Moose::Meta::Role") ) {
128 my $error_message = "$role already has a metaclass, but it does not inherit $metaclass ($meta).";
129 if ( $meta->isa('Moose::Meta::Class') ) {
130 Moose->throw_error($error_message . ' You cannot make the same thing a role and a class. Remove either Moose or Moose::Role.');
131 } else {
132 Moose->throw_error($error_message);
133 }
134 }
135 }
136 else {
137415µs4718µs $meta = $metaclass->initialize($role);
# spent 718µs making 4 calls to Moose::Meta::Role::initialize, avg 180µs/call
138 }
139
14045µs if (defined $meta_name) {
141 # also check for inherited non moose 'meta' method?
142421µs4352µs my $existing = $meta->get_method($meta_name);
# spent 352µs making 4 calls to Class::MOP::Mixin::HasMethods::get_method, avg 88µs/call
14342µs if ($existing && !$existing->isa('Class::MOP::Method::Meta')) {
144 Carp::cluck "Moose::Role is overwriting an existing method named "
145 . "$meta_name in role $role with a method "
146 . "which returns the class's metaclass. If this is "
147 . "actually what you want, you should remove the "
148 . "existing method, otherwise, you should rename or "
149 . "disable this generated method using the "
150 . "'-meta_name' option to 'use Moose::Role'.";
151 }
152420µs42.07ms $meta->_add_meta_method($meta_name);
# spent 2.07ms making 4 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 518µs/call
153 }
154
155422µs return $meta;
156}
157
15818µs1;
159
160# ABSTRACT: The Moose Role
161
- -
164=pod
165
166=head1 NAME
167
168Moose::Role - The Moose Role
169
170=head1 VERSION
171
172version 2.0602
173
174=head1 SYNOPSIS
175
176 package Eq;
177 use Moose::Role; # automatically turns on strict and warnings
178
179 requires 'equal';
180
181 sub no_equal {
182 my ($self, $other) = @_;
183 !$self->equal($other);
184 }
185
186 # ... then in your classes
187
188 package Currency;
189 use Moose; # automatically turns on strict and warnings
190
191 with 'Eq';
192
193 sub equal {
194 my ($self, $other) = @_;
195 $self->as_float == $other->as_float;
196 }
197
198 # ... and also
199
200 package Comparator;
201 use Moose;
202
203 has compare_to => (
204 is => 'ro',
205 does => 'Eq',
206 handles => 'Eq',
207 );
208
209 # ... which allows
210
211 my $currency1 = Currency->new(...);
212 my $currency2 = Currency->new(...);
213 Comparator->new(compare_to => $currency1)->equal($currency2);
214
215=head1 DESCRIPTION
216
217The concept of roles is documented in L<Moose::Manual::Roles>. This document
218serves as API documentation.
219
220=head1 EXPORTED FUNCTIONS
221
222Moose::Role currently supports all of the functions that L<Moose> exports, but
223differs slightly in how some items are handled (see L</CAVEATS> below for
224details).
225
226Moose::Role also offers two role-specific keyword exports:
227
228=over 4
229
230=item B<requires (@method_names)>
231
232Roles can require that certain methods are implemented by any class which
233C<does> the role.
234
235Note that attribute accessors also count as methods for the purposes
236of satisfying the requirements of a role.
237
238=item B<excludes (@role_names)>
239
240Roles can C<exclude> other roles, in effect saying "I can never be combined
241with these C<@role_names>". This is a feature which should not be used
242lightly.
243
244=back
245
246=head2 B<unimport>
247
248Moose::Role offers a way to remove the keywords it exports, through the
249C<unimport> method. You simply have to say C<no Moose::Role> at the bottom of
250your code for this to work.
251
252=head1 METACLASS
253
254When you use Moose::Role, you can specify traits which will be applied to your
255role metaclass:
256
257 use Moose::Role -traits => 'My::Trait';
258
259This is very similar to the attribute traits feature. When you do
260this, your class's C<meta> object will have the specified traits
261applied to it. See L<Moose/Metaclass and Trait Name Resolution> for more
262details.
263
264=head1 APPLYING ROLES
265
266In addition to being applied to a class using the 'with' syntax (see
267L<Moose::Manual::Roles>) and using the L<Moose::Util> 'apply_all_roles'
268method, roles may also be applied to an instance of a class using
269L<Moose::Util> 'apply_all_roles' or the role's metaclass:
270
271 MyApp::Test::SomeRole->meta->apply( $instance );
272
273Doing this creates a new, mutable, anonymous subclass, applies the role to that,
274and reblesses. In a debugger, for example, you will see class names of the
275form C< Moose::Meta::Class::__ANON__::SERIAL::6 >, which means that doing a
276'ref' on your instance may not return what you expect. See L<Moose::Object> for
277'DOES'.
278
279Additional params may be added to the new instance by providing
280'rebless_params'. See L<Moose::Meta::Role::Application::ToInstance>.
281
282=head1 CAVEATS
283
284Role support has only a few caveats:
285
286=over 4
287
288=item *
289
290Roles cannot use the C<extends> keyword; it will throw an exception for now.
291The same is true of the C<augment> and C<inner> keywords (not sure those
292really make sense for roles). All other Moose keywords will be I<deferred>
293so that they can be applied to the consuming class.
294
295=item *
296
297Role composition does its best to B<not> be order-sensitive when it comes to
298conflict resolution and requirements detection. However, it is order-sensitive
299when it comes to method modifiers. All before/around/after modifiers are
300included whenever a role is composed into a class, and then applied in the order
301in which the roles are used. This also means that there is no conflict for
302before/around/after modifiers.
303
304In most cases, this will be a non-issue; however, it is something to keep in
305mind when using method modifiers in a role. You should never assume any
306ordering.
307
308=back
309
310=head1 BUGS
311
312See L<Moose/BUGS> for details on reporting bugs.
313
314=head1 AUTHOR
315
316Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
317
318=head1 COPYRIGHT AND LICENSE
319
320This software is copyright (c) 2012 by Infinity Interactive, Inc..
321
322This is free software; you can redistribute it and/or modify it under
323the same terms as the Perl 5 programming language system itself.
324
325=cut
326
327
328__END__