Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:30 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm
Statements Executed | 11423
Statement Execution Time | 20.9ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 4.59ms | 66.1ms | Moose::Exporter::::BEGIN@11Moose::Exporter::BEGIN@11
384 | 1 | 1 | 4.28ms | 7.33ms | Moose::Exporter::::__ANON__[:263]Moose::Exporter::__ANON__[:263]
31 | 1 | 1 | 2.86ms | 2.92ms | Moose::Exporter::::_remove_keywordsMoose::Exporter::_remove_keywords
59 | 57 | 50 | 2.85ms | 130ms | Moose::Exporter::::__ANON__[:389]Moose::Exporter::__ANON__[:389]
384 | 1 | 1 | 2.31ms | 2.31ms | Moose::Exporter::::_late_curry_wrapperMoose::Exporter::_late_curry_wrapper
1 | 1 | 1 | 685µs | 835µs | Moose::Exporter::::BEGIN@13Moose::Exporter::BEGIN@13
59 | 1 | 1 | 587µs | 782µs | Moose::Exporter::::_strip_traitsMoose::Exporter::_strip_traits
372 | 1 | 1 | 485µs | 485µs | Moose::Exporter::::__ANON__[:193]Moose::Exporter::__ANON__[:193]
1 | 1 | 1 | 414µs | 1.00ms | Moose::Exporter::::BEGIN@12Moose::Exporter::BEGIN@12
5 | 1 | 1 | 403µs | 681µs | Moose::Exporter::::_make_sub_exporter_paramsMoose::Exporter::_make_sub_exporter_params
59 | 1 | 1 | 365µs | 438µs | Moose::Exporter::::_strip_metaclassMoose::Exporter::_strip_metaclass
110 | 1 | 1 | 364µs | 1.00ms | Moose::Exporter::::__ANON__[:255]Moose::Exporter::__ANON__[:255]
31 | 31 | 29 | 318µs | 3.24ms | Moose::Exporter::::__ANON__[:478]Moose::Exporter::__ANON__[:478]
5 | 1 | 1 | 303µs | 3.40ms | Moose::Exporter::::build_import_methodsMoose::Exporter::build_import_methods
50 | 3 | 1 | 163µs | 163µs | Moose::Exporter::::_sub_from_packageMoose::Exporter::_sub_from_package
59 | 1 | 1 | 161µs | 161µs | Moose::Exporter::::_get_callerMoose::Exporter::_get_caller
21 | 1 | 1 | 150µs | 310µs | Moose::Exporter::::__ANON__[:241]Moose::Exporter::__ANON__[:241]
21 | 1 | 1 | 108µs | 119µs | Moose::Exporter::::_curry_wrapperMoose::Exporter::_curry_wrapper
96 | 1 | 2 | 97µs | 97µs | Moose::Exporter::::_flag_as_reexportMoose::Exporter::_flag_as_reexport (xsub)
5 | 1 | 1 | 91µs | 91µs | Moose::Exporter::::_make_init_metaMoose::Exporter::_make_init_meta
5 | 1 | 1 | 71µs | 129µs | Moose::Exporter::::_follow_alsoMoose::Exporter::_follow_also
5 | 5 | 5 | 70µs | 3.47ms | Moose::Exporter::::setup_import_methodsMoose::Exporter::setup_import_methods
16 | 1 | 1 | 68µs | 68µs | Moose::Exporter::::_make_wrapped_sub_with_metaMoose::Exporter::_make_wrapped_sub_with_meta
58 | 1 | 2 | 61µs | 61µs | Moose::Exporter::::_export_is_flaggedMoose::Exporter::_export_is_flagged (xsub)
5 | 1 | 1 | 56µs | 56µs | Moose::Exporter::::_make_import_subMoose::Exporter::_make_import_sub
5 | 5 | 5 | 43µs | 102µs | Moose::Exporter::::importMoose::Exporter::import
11 | 1 | 1 | 43µs | 43µs | Moose::Exporter::::_make_wrapped_subMoose::Exporter::_make_wrapped_sub
5 | 1 | 1 | 35µs | 35µs | Moose::Exporter::::_make_unimport_subMoose::Exporter::_make_unimport_sub
5 | 1 | 1 | 27µs | 27µs | Moose::Exporter::::_follow_also_realMoose::Exporter::_follow_also_real
1 | 1 | 1 | 18µs | 47µs | Moose::Exporter::::BEGIN@386Moose::Exporter::BEGIN@386
1 | 1 | 1 | 15µs | 197µs | Moose::Exporter::::BEGIN@14Moose::Exporter::BEGIN@14
1 | 1 | 1 | 13µs | 16µs | Moose::Exporter::::BEGIN@3Moose::Exporter::BEGIN@3
1 | 1 | 1 | 11µs | 33µs | Moose::Exporter::::BEGIN@206Moose::Exporter::BEGIN@206
1 | 1 | 1 | 11µs | 27µs | Moose::Exporter::::BEGIN@385Moose::Exporter::BEGIN@385
1 | 1 | 1 | 8µs | 26µs | Moose::Exporter::::BEGIN@488Moose::Exporter::BEGIN@488
1 | 1 | 1 | 8µs | 22µs | Moose::Exporter::::BEGIN@498Moose::Exporter::BEGIN@498
1 | 1 | 1 | 7µs | 32µs | Moose::Exporter::::BEGIN@15Moose::Exporter::BEGIN@15
1 | 1 | 1 | 7µs | 16µs | Moose::Exporter::::BEGIN@4Moose::Exporter::BEGIN@4
1 | 1 | 1 | 5µs | 5µs | Moose::Exporter::::BEGIN@17Moose::Exporter::BEGIN@17
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:272]Moose::Exporter::__ANON__[:272]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:294]Moose::Exporter::__ANON__[:294]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:393]Moose::Exporter::__ANON__[:393]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:407]Moose::Exporter::__ANON__[:407]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::__ANON__[:562]Moose::Exporter::__ANON__[:562]
0 | 0 | 0 | 0s | 0s | Moose::Exporter::::_apply_meta_traitsMoose::Exporter::_apply_meta_traits

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Moose::Exporter;
2 |  |  |  |  |
3 | 3 | 20µs | 2 | 19µs | # spent 16µs (13+3) within Moose::Exporter::BEGIN@3 which was called # once (13µs+3µs) by Moose::BEGIN@14 at line 3 use strict; # spent 16µs making 1 call to Moose::Exporter::BEGIN@3 # spent 3µs making 1 call to strict::import
4 | 3 | 47µs | 2 | 24µs | # spent 16µs (7+9) within Moose::Exporter::BEGIN@4 which was called # once (7µs+9µs) by Moose::BEGIN@14 at line 4 use warnings; # spent 16µs making 1 call to Moose::Exporter::BEGIN@4 # spent 9µs making 1 call to warnings::import
5 |  |  |  |  |
6 | 1 | 700ns |  |  | our $VERSION = '0.98';
7 | 1 | 100ns |  |  | our $XS_VERSION = $VERSION;
8 | 1 | 23µs |  |  | $VERSION = eval $VERSION;
9 | 1 | 800ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
10 |  |  |  |  |
11 | 3 | 131µs | 1 | 66.1ms | # spent 66.1ms (4.59+61.5) within Moose::Exporter::BEGIN@11 which was called # once (4.59ms+61.5ms) by Moose::BEGIN@14 at line 11 use Class::MOP; # spent 66.1ms making 1 call to Moose::Exporter::BEGIN@11
12 | 3 | 125µs | 2 | 1.09ms | # spent 1.00ms (414µs+588µs) within Moose::Exporter::BEGIN@12 which was called # once (414µs+588µs) by Moose::BEGIN@14 at line 12 use List::MoreUtils qw( first_index uniq ); # spent 1.00ms making 1 call to Moose::Exporter::BEGIN@12 # spent 92µs making 1 call to Exporter::import
13 | 3 | 109µs | 1 | 835µs | # spent 835µs (685+150) within Moose::Exporter::BEGIN@13 which was called # once (685µs+150µs) by Moose::BEGIN@14 at line 13 use Moose::Util::MetaRole; # spent 835µs making 1 call to Moose::Exporter::BEGIN@13
14 | 3 | 53µs | 3 | 378µs | # spent 197µs (15+182) within Moose::Exporter::BEGIN@14 which was called # once (15µs+182µs) by Moose::BEGIN@14 at line 14 use Sub::Exporter 0.980; # spent 197µs making 1 call to Moose::Exporter::BEGIN@14 # spent 167µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] # spent 15µs making 1 call to UNIVERSAL::VERSION
15 | 3 | 21µs | 2 | 56µs | # spent 32µs (7+24) within Moose::Exporter::BEGIN@15 which was called # once (7µs+24µs) by Moose::BEGIN@14 at line 15 use Sub::Name qw(subname); # spent 32µs making 1 call to Moose::Exporter::BEGIN@15 # spent 24µs making 1 call to Exporter::import
16 |  |  |  |  |
17 | 3 | 728µs | 1 | 5µs | # spent 5µs within Moose::Exporter::BEGIN@17 which was called # once (5µs+0s) by Moose::BEGIN@14 at line 17 use XSLoader; # spent 5µs making 1 call to Moose::Exporter::BEGIN@17
18 |  |  |  |  |
19 | 1 | 111µs | 1 | 102µs | XSLoader::load( 'Moose', $XS_VERSION ); # spent 102µs making 1 call to XSLoader::load
20 |  |  |  |  |
21 | 1 | 200ns |  |  | my %EXPORT_SPEC;
22 |  |  |  |  |
23 |  |  |  |  | # spent 3.47ms (70µs+3.40) within Moose::Exporter::setup_import_methods which was called 5 times, avg 694µs/call: # once (14µs+873µs) by Moose::Meta::Attribute::BEGIN@18 at line 41 of Moose/Util/TypeConstraints.pm # once (14µs+728µs) by Foo::BEGIN@3 at line 121 of Moose.pm # once (13µs+727µs) by MooseX::AttributeHelpers::Trait::Bool::BEGIN@2 at line 91 of Moose/Role.pm # once (14µs+695µs) by MooseX::Types::BEGIN@15 at line 67 of MooseX/Types/CheckedUtilExports.pm # once (14µs+381µs) by SimpleDB::Class::BEGIN@138 at line 13 of MooseX/ClassAttribute.pm sub setup_import_methods {
24 | 15 | 66µs |  |  | my ( $class, %args ) = @_;
25 |  |  |  |  |
26 |  |  |  |  | my $exporting_package = $args{exporting_package} ||= caller();
27 |  |  |  |  |
28 |  |  |  |  | $class->build_import_methods( # spent 3.40ms making 5 calls to Moose::Exporter::build_import_methods, avg 680µs/call
29 |  |  |  |  | %args,
30 |  |  |  |  | install => [qw(import unimport init_meta)]
31 |  |  |  |  | );
32 |  |  |  |  | }
33 |  |  |  |  |
34 |  |  |  |  | # spent 3.40ms (303µs+3.10) within Moose::Exporter::build_import_methods which was called 5 times, avg 680µs/call: # 5 times (303µs+3.10ms) by Moose::Exporter::setup_import_methods at line 28, avg 680µs/call sub build_import_methods {
35 | 75 | 200µs |  |  | my ( $class, %args ) = @_;
36 |  |  |  |  |
37 |  |  |  |  | my $exporting_package = $args{exporting_package} ||= caller();
38 |  |  |  |  |
39 |  |  |  |  | $EXPORT_SPEC{$exporting_package} = \%args;
40 |  |  |  |  |
41 |  |  |  |  | my @exports_from = $class->_follow_also($exporting_package); # spent 129µs making 5 calls to Moose::Exporter::_follow_also, avg 26µs/call
42 |  |  |  |  |
43 |  |  |  |  | my $export_recorder = {};
44 |  |  |  |  | my $is_reexport = {};
45 |  |  |  |  |
46 |  |  |  |  | my $exports = $class->_make_sub_exporter_params( # spent 681µs making 5 calls to Moose::Exporter::_make_sub_exporter_params, avg 136µs/call
47 |  |  |  |  | [ @exports_from, $exporting_package ],
48 |  |  |  |  | $export_recorder,
49 |  |  |  |  | $is_reexport,
50 |  |  |  |  | );
51 |  |  |  |  |
52 |  |  |  |  | my $exporter = Sub::Exporter::build_exporter( # spent 1.64ms making 5 calls to Sub::Exporter::build_exporter, avg 329µs/call
53 |  |  |  |  | {
54 |  |  |  |  | exports => $exports,
55 |  |  |  |  | groups => { default => [':all'] }
56 |  |  |  |  | }
57 |  |  |  |  | );
58 |  |  |  |  |
59 |  |  |  |  | my %methods;
60 |  |  |  |  | $methods{import} = $class->_make_import_sub( # spent 56µs making 5 calls to Moose::Exporter::_make_import_sub, avg 11µs/call
61 |  |  |  |  | $exporting_package,
62 |  |  |  |  | $exporter,
63 |  |  |  |  | \@exports_from,
64 |  |  |  |  | $is_reexport
65 |  |  |  |  | );
66 |  |  |  |  |
67 |  |  |  |  | $methods{unimport} = $class->_make_unimport_sub( # spent 35µs making 5 calls to Moose::Exporter::_make_unimport_sub, avg 7µs/call
68 |  |  |  |  | $exporting_package,
69 |  |  |  |  | $exports,
70 |  |  |  |  | $export_recorder,
71 |  |  |  |  | $is_reexport
72 |  |  |  |  | );
73 |  |  |  |  |
74 |  |  |  |  | $methods{init_meta} = $class->_make_init_meta( # spent 91µs making 5 calls to Moose::Exporter::_make_init_meta, avg 18µs/call
75 |  |  |  |  | $exporting_package,
76 |  |  |  |  | \%args
77 |  |  |  |  | );
78 |  |  |  |  |
79 |  |  |  |  | my $package = Class::MOP::Package->initialize($exporting_package); # spent 196µs making 5 calls to Class::MOP::Package::initialize, avg 39µs/call
80 |  |  |  |  | for my $to_install ( @{ $args{install} || [] } ) {
81 | 40 | 47µs |  |  | my $symbol = '&' . $to_install;
82 |  |  |  |  | next
83 |  |  |  |  | unless $methods{$to_install} # spent 174µs making 10 calls to Class::MOP::Package::has_package_symbol, avg 17µs/call
84 |  |  |  |  | && !$package->has_package_symbol($symbol);
85 |  |  |  |  | $package->add_package_symbol( $symbol, $methods{$to_install} ); # spent 94µs making 10 calls to Class::MOP::Package::add_package_symbol, avg 9µs/call
86 |  |  |  |  | }
87 |  |  |  |  |
88 |  |  |  |  | return ( $methods{import}, $methods{unimport}, $methods{init_meta} );
89 |  |  |  |  | }
90 |  |  |  |  |
91 |  |  |  |  | {
92 | 2 | 1µs |  |  | my $seen = {};
93 |  |  |  |  |
94 |  |  |  |  | # spent 129µs (71+58) within Moose::Exporter::_follow_also which was called 5 times, avg 26µs/call: # 5 times (71µs+58µs) by Moose::Exporter::build_import_methods at line 41, avg 26µs/call sub _follow_also {
95 | 20 | 90µs |  |  | my $class = shift;
96 |  |  |  |  | my $exporting_package = shift;
97 |  |  |  |  |
98 |  |  |  |  | local %$seen = ( $exporting_package => 1 );
99 |  |  |  |  |
100 |  |  |  |  | return uniq( _follow_also_real($exporting_package) ); # spent 32µs making 5 calls to List::MoreUtils::uniq, avg 6µs/call # spent 27µs making 5 calls to Moose::Exporter::_follow_also_real, avg 5µs/call
101 |  |  |  |  | }
102 |  |  |  |  |
103 |  |  |  |  | # spent 27µs within Moose::Exporter::_follow_also_real which was called 5 times, avg 5µs/call: # 5 times (27µs+0s) by Moose::Exporter::_follow_also at line 100, avg 5µs/call sub _follow_also_real {
104 | 20 | 42µs |  |  | my $exporting_package = shift;
105 |  |  |  |  |
106 |  |  |  |  | if ( !exists $EXPORT_SPEC{$exporting_package} ) {
107 |  |  |  |  | my $loaded = Class::MOP::is_class_loaded($exporting_package);
108 |  |  |  |  |
109 |  |  |  |  | die "Package in also ($exporting_package) does not seem to "
110 |  |  |  |  | . "use Moose::Exporter"
111 |  |  |  |  | . ( $loaded ? "" : " (is it loaded?)" );
112 |  |  |  |  | }
113 |  |  |  |  |
114 |  |  |  |  | my $also = $EXPORT_SPEC{$exporting_package}{also};
115 |  |  |  |  |
116 |  |  |  |  | return unless defined $also;
117 |  |  |  |  |
118 |  |  |  |  | my @also = ref $also ? @{$also} : $also;
119 |  |  |  |  |
120 |  |  |  |  | for my $package (@also) {
121 |  |  |  |  | die
122 |  |  |  |  | "Circular reference in 'also' parameter to Moose::Exporter between $exporting_package and $package"
123 |  |  |  |  | if $seen->{$package};
124 |  |  |  |  |
125 |  |  |  |  | $seen->{$package} = 1;
126 |  |  |  |  | }
127 |  |  |  |  |
128 |  |  |  |  | return @also, map { _follow_also_real($_) } @also;
129 |  |  |  |  | }
130 |  |  |  |  | }
131 |  |  |  |  |
132 |  |  |  |  | # spent 681µs (403+278) within Moose::Exporter::_make_sub_exporter_params which was called 5 times, avg 136µs/call: # 5 times (403µs+278µs) by Moose::Exporter::build_import_methods at line 46, avg 136µs/call sub _make_sub_exporter_params {
133 | 35 | 31µs |  |  | my $class = shift;
134 |  |  |  |  | my $packages = shift;
135 |  |  |  |  | my $export_recorder = shift;
136 |  |  |  |  | my $is_reexport = shift;
137 |  |  |  |  |
138 |  |  |  |  | my %exports;
139 |  |  |  |  |
140 |  |  |  |  | for my $package ( @{$packages} ) {
141 | 20 | 31µs |  |  | my $args = $EXPORT_SPEC{$package}
142 |  |  |  |  | or die "The $package package does not use Moose::Exporter\n";
143 |  |  |  |  |
144 |  |  |  |  | for my $name ( @{ $args->{with_meta} } ) {
145 | 48 | 53µs | 16 | 51µs | my $sub = $class->_sub_from_package( $package, $name ) # spent 51µs making 16 calls to Moose::Exporter::_sub_from_package, avg 3µs/call
146 |  |  |  |  | or next;
147 |  |  |  |  |
148 |  |  |  |  | my $fq_name = $package . '::' . $name;
149 |  |  |  |  |
150 |  |  |  |  | $exports{$name} = $class->_make_wrapped_sub_with_meta( # spent 68µs making 16 calls to Moose::Exporter::_make_wrapped_sub_with_meta, avg 4µs/call
151 |  |  |  |  | $fq_name,
152 |  |  |  |  | $sub,
153 |  |  |  |  | $export_recorder,
154 |  |  |  |  | );
155 |  |  |  |  | }
156 |  |  |  |  |
157 |  |  |  |  | for my $name ( @{ $args->{with_caller} } ) {
158 | 33 | 40µs | 11 | 41µs | my $sub = $class->_sub_from_package( $package, $name ) # spent 41µs making 11 calls to Moose::Exporter::_sub_from_package, avg 4µs/call
159 |  |  |  |  | or next;
160 |  |  |  |  |
161 |  |  |  |  | my $fq_name = $package . '::' . $name;
162 |  |  |  |  |
163 |  |  |  |  | $exports{$name} = $class->_make_wrapped_sub( # spent 43µs making 11 calls to Moose::Exporter::_make_wrapped_sub, avg 4µs/call
164 |  |  |  |  | $fq_name,
165 |  |  |  |  | $sub,
166 |  |  |  |  | $export_recorder,
167 |  |  |  |  | );
168 |  |  |  |  | }
169 |  |  |  |  |
170 |  |  |  |  | for my $name ( @{ $args->{as_is} } ) {
171 | 108 | 81µs |  |  | my ( $sub, $coderef_name );
172 |  |  |  |  |
173 | 62 | 51µs |  |  | if ( ref $name ) {
174 |  |  |  |  | $sub = $name;
175 |  |  |  |  |
176 |  |  |  |  | my $coderef_pkg;
177 |  |  |  |  | ( $coderef_pkg, $coderef_name ) # spent 5µs making 4 calls to Class::MOP::get_code_info, avg 1µs/call
178 |  |  |  |  | = Class::MOP::get_code_info($name);
179 |  |  |  |  |
180 |  |  |  |  | if ( $coderef_pkg ne $package ) {
181 |  |  |  |  | $is_reexport->{$coderef_name} = 1;
182 |  |  |  |  | }
183 |  |  |  |  | }
184 |  |  |  |  | else {
185 |  |  |  |  | $sub = $class->_sub_from_package( $package, $name ) # spent 71µs making 23 calls to Moose::Exporter::_sub_from_package, avg 3µs/call
186 |  |  |  |  | or next;
187 |  |  |  |  |
188 |  |  |  |  | $coderef_name = $name;
189 |  |  |  |  | }
190 |  |  |  |  |
191 |  |  |  |  | $export_recorder->{$sub} = 1;
192 |  |  |  |  |
193 | 372 | 677µs |  |  | # spent 485µs within Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:193] which was called 372 times, avg 1µs/call: # 372 times (485µs+0s) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 1µs/call $exports{$coderef_name} = sub {$sub};
194 |  |  |  |  | }
195 |  |  |  |  | }
196 |  |  |  |  |
197 |  |  |  |  | return \%exports;
198 |  |  |  |  | }
199 |  |  |  |  |
200 |  |  |  |  | # spent 163µs within Moose::Exporter::_sub_from_package which was called 50 times, avg 3µs/call: # 23 times (71µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 185, avg 3µs/call # 16 times (51µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 145, avg 3µs/call # 11 times (41µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 158, avg 4µs/call sub _sub_from_package {
201 | 250 | 130µs |  |  | my $sclass = shift;
202 |  |  |  |  | my $package = shift;
203 |  |  |  |  | my $name = shift;
204 |  |  |  |  |
205 | 50 | 49µs |  |  | my $sub = do {
206 | 3 | 918µs | 2 | 54µs | # spent 33µs (11+21) within Moose::Exporter::BEGIN@206 which was called # once (11µs+21µs) by Moose::BEGIN@14 at line 206 no strict 'refs'; # spent 33µs making 1 call to Moose::Exporter::BEGIN@206 # spent 22µs making 1 call to strict::unimport
207 |  |  |  |  | \&{ $package . '::' . $name };
208 |  |  |  |  | };
209 |  |  |  |  |
210 |  |  |  |  | return $sub if defined &$sub;
211 |  |  |  |  |
212 |  |  |  |  | Carp::cluck "Trying to export undefined sub ${package}::${name}";
213 |  |  |  |  |
214 |  |  |  |  | return;
215 |  |  |  |  | }
216 |  |  |  |  |
217 | 1 | 200ns |  |  | our $CALLER;
218 |  |  |  |  |
219 |  |  |  |  | # spent 43µs within Moose::Exporter::_make_wrapped_sub which was called 11 times, avg 4µs/call: # 11 times (43µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 163, avg 4µs/call sub _make_wrapped_sub {
220 | 55 | 50µs |  |  | my $self = shift;
221 |  |  |  |  | my $fq_name = shift;
222 |  |  |  |  | my $sub = shift;
223 |  |  |  |  | my $export_recorder = shift;
224 |  |  |  |  |
225 |  |  |  |  | # We need to set the package at import time, so that when
226 |  |  |  |  | # package Foo imports has(), we capture "Foo" as the
227 |  |  |  |  | # package. This lets other packages call Foo::has() and get
228 |  |  |  |  | # the right package. This is done for backwards compatibility
229 |  |  |  |  | # with existing production code, not because this is a good
230 |  |  |  |  | # idea ;)
231 |  |  |  |  | # spent 310µs (150+160) within Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:241] which was called 21 times, avg 15µs/call: # 21 times (150µs+160µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 15µs/call return sub {
232 | 105 | 169µs |  |  | my $caller = $CALLER;
233 |  |  |  |  |
234 |  |  |  |  | my $wrapper = $self->_curry_wrapper( $sub, $fq_name, $caller ); # spent 119µs making 21 calls to Moose::Exporter::_curry_wrapper, avg 6µs/call
235 |  |  |  |  |
236 |  |  |  |  | my $sub = subname( $fq_name => $wrapper ); # spent 41µs making 21 calls to Sub::Name::subname, avg 2µs/call
237 |  |  |  |  |
238 |  |  |  |  | $export_recorder->{$sub} = 1;
239 |  |  |  |  |
240 |  |  |  |  | return $sub;
241 |  |  |  |  | };
242 |  |  |  |  | }
243 |  |  |  |  |
244 |  |  |  |  | # spent 68µs within Moose::Exporter::_make_wrapped_sub_with_meta which was called 16 times, avg 4µs/call: # 16 times (68µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 150, avg 4µs/call sub _make_wrapped_sub_with_meta {
245 | 80 | 79µs |  |  | my $self = shift;
246 |  |  |  |  | my $fq_name = shift;
247 |  |  |  |  | my $sub = shift;
248 |  |  |  |  | my $export_recorder = shift;
249 |  |  |  |  |
250 |  |  |  |  | # spent 7.33ms (4.28+3.06) within Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:263] which was called 384 times, avg 19µs/call: # 384 times (4.28ms+3.06ms) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 19µs/call return sub {
251 | 1920 | 4.59ms |  |  | my $caller = $CALLER;
252 |  |  |  |  |
253 |  |  |  |  | my $wrapper = $self->_late_curry_wrapper(
254 |  |  |  |  | $sub, $fq_name,
255 | 110 | 350µs | 494 | 2.95ms | # spent 1.00ms (364µs+637µs) within Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:255] which was called 110 times, avg 9µs/call: # 110 times (364µs+637µs) by Moose::Role::after or Moose::Role::around or Moose::Role::before or Moose::Role::has or Moose::Role::requires or Moose::Role::with or Moose::extends or Moose::has or Moose::with at line 292, avg 9µs/call sub { Class::MOP::class_of(shift) } => $caller # spent 2.31ms making 384 calls to Moose::Exporter::_late_curry_wrapper, avg 6µs/call # spent 637µs making 110 calls to Class::MOP::class_of, avg 6µs/call
256 |  |  |  |  | );
257 |  |  |  |  |
258 |  |  |  |  | my $sub = subname( $fq_name => $wrapper ); # spent 745µs making 384 calls to Sub::Name::subname, avg 2µs/call
259 |  |  |  |  |
260 |  |  |  |  | $export_recorder->{$sub} = 1;
261 |  |  |  |  |
262 |  |  |  |  | return $sub;
263 |  |  |  |  | };
264 |  |  |  |  | }
265 |  |  |  |  |
266 |  |  |  |  | # spent 119µs (108+11) within Moose::Exporter::_curry_wrapper which was called 21 times, avg 6µs/call: # 21 times (108µs+11µs) by Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:241] at line 234, avg 6µs/call sub _curry_wrapper {
267 | 147 | 134µs |  |  | my $class = shift;
268 |  |  |  |  | my $sub = shift;
269 |  |  |  |  | my $fq_name = shift;
270 |  |  |  |  | my @extra = @_;
271 |  |  |  |  |
272 | 62 | 209µs | 62 | 11.8ms | my $wrapper = sub { $sub->( @extra, @_ ) }; # spent 11.3ms making 1 call to MooseX::ClassAttribute::class_has # spent 263µs making 60 calls to MooseX::Types::CheckedUtilExports::__ANON__[MooseX/Types/CheckedUtilExports.pm:63], avg 4µs/call # spent 251µs making 1 call to MooseX::Types::CheckedUtilExports::class_type
273 |  |  |  |  | if ( my $proto = prototype $sub ) { # spent 11µs making 2 calls to Scalar::Util::set_prototype, avg 5µs/call
274 |  |  |  |  |
275 |  |  |  |  | # XXX - Perl's prototype sucks. Use & to make set_prototype
276 |  |  |  |  | # ignore the fact that we're passing "private variables"
277 |  |  |  |  | &Scalar::Util::set_prototype( $wrapper, $proto );
278 |  |  |  |  | }
279 |  |  |  |  | return $wrapper;
280 |  |  |  |  | }
281 |  |  |  |  |
282 |  |  |  |  | # spent 2.31ms within Moose::Exporter::_late_curry_wrapper which was called 384 times, avg 6µs/call: # 384 times (2.31ms+0s) by Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:263] at line 255, avg 6µs/call sub _late_curry_wrapper {
283 | 3072 | 2.52ms |  |  | my $class = shift;
284 |  |  |  |  | my $sub = shift;
285 |  |  |  |  | my $fq_name = shift;
286 |  |  |  |  | my $extra = shift;
287 |  |  |  |  | my @ex_args = @_;
288 |  |  |  |  |
289 |  |  |  |  | my $wrapper = sub {
290 |  |  |  |  |
291 |  |  |  |  | # resolve curried arguments at runtime via this closure
292 | 220 | 718µs | 110 | 1.00ms | my @curry = ( $extra->(@ex_args) ); # spent 1.00ms making 110 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:255], avg 9µs/call
293 |  |  |  |  | return $sub->( @curry, @_ ); # spent 605ms making 17 calls to Moose::extends, avg 35.6ms/call, recursion: max depth 1, time 4.46ms # spent 138ms making 11 calls to Moose::with, avg 12.5ms/call # spent 43.3ms making 34 calls to Moose::has, avg 1.27ms/call # spent 44.9ms making 13 calls to Moose::Role::with, avg 3.46ms/call, recursion: max depth 1, time 2.17ms # spent 1.43ms making 14 calls to Moose::Role::has, avg 102µs/call # spent 213µs making 2 calls to Moose::Role::requires, avg 106µs/call # spent 208µs making 10 calls to Moose::Role::around, avg 21µs/call # spent 144µs making 5 calls to Moose::Role::before, avg 29µs/call # spent 90µs making 4 calls to Moose::Role::after, avg 23µs/call
294 |  |  |  |  | };
295 |  |  |  |  |
296 |  |  |  |  | if ( my $proto = prototype $sub ) {
297 |  |  |  |  |
298 |  |  |  |  | # XXX - Perl's prototype sucks. Use & to make set_prototype
299 |  |  |  |  | # ignore the fact that we're passing "private variables"
300 |  |  |  |  | &Scalar::Util::set_prototype( $wrapper, $proto );
301 |  |  |  |  | }
302 |  |  |  |  | return $wrapper;
303 |  |  |  |  | }
304 |  |  |  |  |
305 |  |  |  |  | # spent 56µs within Moose::Exporter::_make_import_sub which was called 5 times, avg 11µs/call: # 5 times (56µs+0s) by Moose::Exporter::build_import_methods at line 60, avg 11µs/call sub _make_import_sub {
306 | 30 | 58µs |  |  | shift;
307 |  |  |  |  | my $exporting_package = shift;
308 |  |  |  |  | my $exporter = shift;
309 |  |  |  |  | my $exports_from = shift;
310 |  |  |  |  | my $is_reexport = shift;
311 |  |  |  |  |
312 |  |  |  |  | # spent 130ms (2.85+128) within Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:389] which was called 59 times, avg 2.21ms/call: # 2 times (75µs+2.32ms) by MooseX::Types::import at line 362 of MooseX/Types.pm, avg 1.20ms/call # 2 times (61µs+2.03ms) by MooseX::Types::import at line 365 of MooseX/Types.pm, avg 1.04ms/call # once (50µs+24.6ms) by SimpleDB::Class::BEGIN@138 at line 138 of ../lib/SimpleDB/Class.pm # once (62µs+3.14ms) by MooseX::AttributeHelpers::Collection::ImmutableHash::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Collection/ImmutableHash.pm # once (70µs+2.74ms) by SimpleDB::Client::BEGIN@51 at line 51 of SimpleDB/Client.pm # once (72µs+2.66ms) by Foo::BEGIN@3 at line 3 of lib/Foo.pm # once (65µs+2.51ms) by SimpleDB::Class::Domain::BEGIN@17 at line 17 of ../lib/SimpleDB/Class/Domain.pm # once (66µs+2.49ms) by Foo::Domain::BEGIN@3 at line 3 of lib/Foo/Domain.pm # once (69µs+2.45ms) by MooseX::ClassAttribute::Meta::Method::Accessor::BEGIN@6 at line 6 of MooseX/ClassAttribute/Meta/Method/Accessor.pm # once (66µs+2.44ms) by SimpleDB::Class::ResultSet::BEGIN@21 at line 21 of ../lib/SimpleDB/Class/ResultSet.pm # once (69µs+2.40ms) by Foo::Child::BEGIN@3 at line 3 of lib/Foo/Child.pm # once (65µs+2.39ms) by MooseX::AttributeHelpers::Collection::Array::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Collection/Array.pm # once (63µs+2.35ms) by MooseX::AttributeHelpers::Number::BEGIN@2 at line 2 of MooseX/AttributeHelpers/Number.pm # once (59µs+2.33ms) by MooseX::AttributeHelpers::Collection::Hash::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Collection/Hash.pm # once (47µs+2.31ms) by MooseX::Types::Base::BEGIN@2 at line 2 of MooseX/Types/Base.pm # once (57µs+2.28ms) by MooseX::AttributeHelpers::Collection::List::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Collection/List.pm # once (61µs+2.23ms) by MooseX::AttributeHelpers::Collection::Bag::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Collection/Bag.pm # once (57µs+2.23ms) by Foo::Parent::BEGIN@3 at line 3 of lib/Foo/Parent.pm # once (53µs+2.23ms) by MooseX::AttributeHelpers::Bool::BEGIN@2 at line 2 of MooseX/AttributeHelpers/Bool.pm # once (47µs+2.22ms) by Foo::SubChild::BEGIN@3 at line 3 of lib/Foo/SubChild.pm # once (47µs+2.18ms) by MooseX::AttributeHelpers::Counter::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Counter.pm # once (42µs+2.17ms) by MooseX::Types::BEGIN@2 at line 2 of MooseX/Types.pm # once (64µs+2.12ms) by SimpleDB::Class::Cache::BEGIN@29 at line 29 of ../lib/SimpleDB/Class/Cache.pm # once (55µs+2.09ms) by MooseX::AttributeHelpers::String::BEGIN@3 at line 3 of MooseX/AttributeHelpers/String.pm # once (42µs+2.09ms) by SimpleDB::Class::Item::BEGIN@17 at line 17 of ../lib/SimpleDB/Class/Item.pm # once (44µs+2.06ms) by MooseX::AttributeHelpers::Meta::Method::Provided::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Meta/Method/Provided.pm # once (41µs+1.97ms) by MooseX::AttributeHelpers::Meta::Method::Curried::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Meta/Method/Curried.pm # once (41µs+1.95ms) by SimpleDB::Class::SQL::BEGIN@17 at line 17 of ../lib/SimpleDB/Class/SQL.pm # once (41µs+1.94ms) by SimpleDB::Class::BEGIN@137 at line 137 of ../lib/SimpleDB/Class.pm # once (49µs+1.89ms) by MooseX::AttributeHelpers::Trait::Counter::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Trait/Counter.pm # once (68µs+1.75ms) by SimpleDB::Class::Role::Itemized::BEGIN@3 at line 3 of ../lib/SimpleDB/Class/Role/Itemized.pm # once (63µs+1.75ms) by MooseX::AttributeHelpers::Trait::Number::BEGIN@2 at line 2 of MooseX/AttributeHelpers/Trait/Number.pm # once (45µs+1.61ms) by MooseX::AttributeHelpers::Trait::Bool::BEGIN@2 at line 2 of MooseX/AttributeHelpers/Trait/Bool.pm # once (43µs+1.46ms) by MooseX::AttributeHelpers::MethodProvider::String::BEGIN@3 at line 3 of MooseX/AttributeHelpers/MethodProvider/String.pm # once (46µs+1.45ms) by MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@8 at line 8 of MooseX/ClassAttribute/Role/Meta/Attribute.pm # once (43µs+1.44ms) by MooseX::AttributeHelpers::Trait::Collection::Array::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Trait/Collection/Array.pm # once (45µs+1.43ms) by MooseX::AttributeHelpers::Trait::Collection::Bag::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Trait/Collection/Bag.pm # once (42µs+1.41ms) by MooseX::AttributeHelpers::MethodProvider::Hash::BEGIN@2 at line 2 of MooseX/AttributeHelpers/MethodProvider/Hash.pm # once (46µs+1.40ms) by MooseX::AttributeHelpers::MethodProvider::Counter::BEGIN@3 at line 3 of MooseX/AttributeHelpers/MethodProvider/Counter.pm # once (41µs+1.38ms) by MooseX::AttributeHelpers::Trait::String::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Trait/String.pm # once (41µs+1.36ms) by MooseX::AttributeHelpers::MethodProvider::Array::BEGIN@2 at line 2 of MooseX/AttributeHelpers/MethodProvider/Array.pm # once (43µs+1.36ms) by MooseX::AttributeHelpers::Trait::Collection::Hash::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Trait/Collection/Hash.pm # once (45µs+1.36ms) by MooseX::AttributeHelpers::Trait::Collection::List::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Trait/Collection/List.pm # once (43µs+1.35ms) by MooseX::AttributeHelpers::Trait::Collection::ImmutableHash::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Trait/Collection/ImmutableHash.pm # once (41µs+1.36ms) by MooseX::AttributeHelpers::MethodProvider::ImmutableHash::BEGIN@2 at line 2 of MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm # once (42µs+1.35ms) by MooseX::AttributeHelpers::MethodProvider::List::BEGIN@2 at line 2 of MooseX/AttributeHelpers/MethodProvider/List.pm # once (40µs+1.35ms) by MooseX::AttributeHelpers::Trait::Base::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Trait/Base.pm # once (41µs+1.33ms) by MooseX::AttributeHelpers::Trait::Collection::BEGIN@3 at line 3 of MooseX/AttributeHelpers/Trait/Collection.pm # once (41µs+1.32ms) by MooseX::AttributeHelpers::MethodProvider::Bag::BEGIN@2 at line 2 of MooseX/AttributeHelpers/MethodProvider/Bag.pm # once (41µs+1.32ms) by MooseX::AttributeHelpers::MethodProvider::Bool::BEGIN@3 at line 3 of MooseX/AttributeHelpers/MethodProvider/Bool.pm # once (40µs+1.31ms) by MooseX::ClassAttribute::Role::Meta::Class::BEGIN@10 at line 10 of MooseX/ClassAttribute/Role/Meta/Class.pm # once (53µs+1.21ms) by Moose::BEGIN@34 at line 34 of Moose.pm # once (35µs+1.16ms) by MooseX::Types::Base::BEGIN@13 at line 13 of MooseX/Types/Base.pm # once (34µs+1.16ms) by MooseX::Types::BEGIN@10 at line 10 of MooseX/Types.pm # once (32µs+1.15ms) by MooseX::AttributeHelpers::Trait::Collection::Bag::BEGIN@4 at line 4 of MooseX/AttributeHelpers/Trait/Collection/Bag.pm # once (33µs+1.14ms) by Moose::Role::BEGIN@19 at line 19 of Moose/Role.pm # once (29µs+1.13ms) by MooseX::AttributeHelpers::Trait::Base::BEGIN@4 at line 4 of MooseX/AttributeHelpers/Trait/Base.pm return sub {
313 |  |  |  |  |
314 |  |  |  |  | # I think we could use Sub::Exporter's collector feature
315 |  |  |  |  | # to do this, but that would be rather gross, since that
316 |  |  |  |  | # feature isn't really designed to return a value to the
317 |  |  |  |  | # caller of the exporter sub.
318 |  |  |  |  | #
319 |  |  |  |  | # Also, this makes sure we preserve backwards compat for
320 |  |  |  |  | # _get_caller, so it always sees the arguments in the
321 |  |  |  |  | # expected order.
322 | 1062 | 1.57ms |  |  | my $traits;
323 |  |  |  |  | ( $traits, @_ ) = _strip_traits(@_); # spent 782µs making 59 calls to Moose::Exporter::_strip_traits, avg 13µs/call
324 |  |  |  |  |
325 |  |  |  |  | my $metaclass;
326 |  |  |  |  | ( $metaclass, @_ ) = _strip_metaclass(@_); # spent 438µs making 59 calls to Moose::Exporter::_strip_metaclass, avg 7µs/call
327 |  |  |  |  | $metaclass
328 |  |  |  |  | = Moose::Util::resolve_metaclass_alias( 'Class' => $metaclass )
329 |  |  |  |  | if defined $metaclass && length $metaclass;
330 |  |  |  |  |
331 |  |  |  |  | # Normally we could look at $_[0], but in some weird cases
332 |  |  |  |  | # (involving goto &Moose::import), $_[0] ends as something
333 |  |  |  |  | # else (like Squirrel).
334 |  |  |  |  | my $class = $exporting_package;
335 |  |  |  |  |
336 |  |  |  |  | $CALLER = _get_caller(@_); # spent 161µs making 59 calls to Moose::Exporter::_get_caller, avg 3µs/call
337 |  |  |  |  |
338 |  |  |  |  | # this works because both pragmas set $^H (see perldoc
339 |  |  |  |  | # perlvar) which affects the current compilation -
340 |  |  |  |  | # i.e. the file who use'd us - which is why we don't need
341 |  |  |  |  | # to do anything special to make it affect that file
342 |  |  |  |  | # rather than this one (which is already compiled)
343 |  |  |  |  |
344 |  |  |  |  | strict->import; # spent 187µs making 59 calls to strict::import, avg 3µs/call
345 |  |  |  |  | warnings->import; # spent 640µs making 59 calls to warnings::import, avg 11µs/call
346 |  |  |  |  |
347 |  |  |  |  | my $did_init_meta;
348 | 59 | 305µs | 59 | 116µs | for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) { # spent 116µs making 59 calls to UNIVERSAL::can, avg 2µs/call
349 |  |  |  |  |
350 |  |  |  |  | # init_meta can apply a role, which when loaded uses
351 |  |  |  |  | # Moose::Exporter, which in turn sets $CALLER, so we need
352 |  |  |  |  | # to protect against that.
353 | 147 | 160µs |  |  | local $CALLER = $CALLER;
354 |  |  |  |  | $c->init_meta( for_class => $CALLER, metaclass => $metaclass ); # spent 30.6ms making 26 calls to Moose::init_meta, avg 1.18ms/call # spent 24.2ms making 1 call to MooseX::ClassAttribute::init_meta # spent 6.86ms making 22 calls to Moose::Role::init_meta, avg 312µs/call
355 |  |  |  |  | $did_init_meta = 1;
356 |  |  |  |  | }
357 |  |  |  |  |
358 |  |  |  |  | if ( $did_init_meta && @{$traits} ) {
359 |  |  |  |  |
360 |  |  |  |  | # The traits will use Moose::Role, which in turn uses
361 |  |  |  |  | # Moose::Exporter, which in turn sets $CALLER, so we need
362 |  |  |  |  | # to protect against that.
363 |  |  |  |  | local $CALLER = $CALLER;
364 |  |  |  |  | _apply_meta_traits( $CALLER, $traits );
365 |  |  |  |  | }
366 |  |  |  |  | elsif ( @{$traits} ) {
367 |  |  |  |  | require Moose;
368 |  |  |  |  | Moose->throw_error(
369 |  |  |  |  | "Cannot provide traits when $class does not have an init_meta() method"
370 |  |  |  |  | );
371 |  |  |  |  | }
372 |  |  |  |  |
373 |  |  |  |  | my ( undef, @args ) = @_;
374 |  |  |  |  | my $extra = shift @args if ref $args[0] eq 'HASH';
375 |  |  |  |  |
376 |  |  |  |  | $extra ||= {};
377 | 110 | 48µs |  |  | if ( !$extra->{into} ) {
378 |  |  |  |  | $extra->{into_level} ||= 0;
379 |  |  |  |  | $extra->{into_level}++;
380 |  |  |  |  | }
381 |  |  |  |  |
382 |  |  |  |  | $class->$exporter( $extra, @args ); # spent 63.5ms making 59 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:756], avg 1.08ms/call
383 |  |  |  |  |
384 |  |  |  |  | for my $name ( keys %{$is_reexport} ) {
385 | 3 | 38µs | 2 | 43µs | # spent 27µs (11+16) within Moose::Exporter::BEGIN@385 which was called # once (11µs+16µs) by Moose::BEGIN@14 at line 385 no strict 'refs'; # spent 27µs making 1 call to Moose::Exporter::BEGIN@385 # spent 16µs making 1 call to strict::unimport
386 | 3 | 582µs | 2 | 76µs | # spent 47µs (18+29) within Moose::Exporter::BEGIN@386 which was called # once (18µs+29µs) by Moose::BEGIN@14 at line 386 no warnings 'once'; # spent 47µs making 1 call to Moose::Exporter::BEGIN@386 # spent 28µs making 1 call to warnings::unimport
387 | 96 | 471µs | 96 | 97µs | _flag_as_reexport( \*{ join q{::}, $CALLER, $name } ); # spent 97µs making 96 calls to Moose::Exporter::_flag_as_reexport, avg 1µs/call
388 |  |  |  |  | }
389 |  |  |  |  | };
390 |  |  |  |  | }
391 |  |  |  |  |
392 |  |  |  |  | # spent 782µs (587+194) within Moose::Exporter::_strip_traits which was called 59 times, avg 13µs/call: # 59 times (587µs+194µs) by Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:389] at line 323, avg 13µs/call sub _strip_traits {
393 | 181 | 826µs | 59 | 194µs | my $idx = first_index { $_ eq '-traits' } @_; # spent 194µs making 59 calls to List::MoreUtils::firstidx, avg 3µs/call
394 |  |  |  |  |
395 |  |  |  |  | return ( [], @_ ) unless $idx >= 0 && $#_ >= $idx + 1;
396 |  |  |  |  |
397 |  |  |  |  | my $traits = $_[ $idx + 1 ];
398 |  |  |  |  |
399 |  |  |  |  | splice @_, $idx, 2;
400 |  |  |  |  |
401 |  |  |  |  | $traits = [$traits] unless ref $traits;
402 |  |  |  |  |
403 |  |  |  |  | return ( $traits, @_ );
404 |  |  |  |  | }
405 |  |  |  |  |
406 |  |  |  |  | # spent 438µs (365+72) within Moose::Exporter::_strip_metaclass which was called 59 times, avg 7µs/call: # 59 times (365µs+72µs) by Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:389] at line 326, avg 7µs/call sub _strip_metaclass {
407 | 181 | 468µs | 59 | 72µs | my $idx = first_index { $_ eq '-metaclass' } @_; # spent 72µs making 59 calls to List::MoreUtils::firstidx, avg 1µs/call
408 |  |  |  |  |
409 |  |  |  |  | return ( undef, @_ ) unless $idx >= 0 && $#_ >= $idx + 1;
410 |  |  |  |  |
411 |  |  |  |  | my $metaclass = $_[ $idx + 1 ];
412 |  |  |  |  |
413 |  |  |  |  | splice @_, $idx, 2;
414 |  |  |  |  |
415 |  |  |  |  | return ( $metaclass, @_ );
416 |  |  |  |  | }
417 |  |  |  |  |
418 |  |  |  |  | sub _apply_meta_traits {
419 |  |  |  |  | my ( $class, $traits ) = @_;
420 |  |  |  |  |
421 |  |  |  |  | return unless @{$traits};
422 |  |  |  |  |
423 |  |  |  |  | my $meta = Class::MOP::class_of($class);
424 |  |  |  |  |
425 |  |  |  |  | my $type = ( split /::/, ref $meta )[-1]
426 |  |  |  |  | or Moose->throw_error(
427 |  |  |  |  | 'Cannot determine metaclass type for trait application . Meta isa '
428 |  |  |  |  | . ref $meta );
429 |  |  |  |  |
430 |  |  |  |  | my @resolved_traits = map {
431 |  |  |  |  | ref $_
432 |  |  |  |  | ? $_
433 |  |  |  |  | : Moose::Util::resolve_metatrait_alias( $type => $_ )
434 |  |  |  |  | } @$traits;
435 |  |  |  |  |
436 |  |  |  |  | return unless @resolved_traits;
437 |  |  |  |  |
438 |  |  |  |  | my %args = ( for => $class );
439 |  |  |  |  |
440 |  |  |  |  | if ( $meta->isa('Moose::Meta::Role') ) {
441 |  |  |  |  | $args{role_metaroles} = { role => \@resolved_traits };
442 |  |  |  |  | }
443 |  |  |  |  | else {
444 |  |  |  |  | $args{class_metaroles} = { class => \@resolved_traits };
445 |  |  |  |  | }
446 |  |  |  |  |
447 |  |  |  |  | Moose::Util::MetaRole::apply_metaroles(%args);
448 |  |  |  |  | }
449 |  |  |  |  |
450 |  |  |  |  | # spent 161µs within Moose::Exporter::_get_caller which was called 59 times, avg 3µs/call: # 59 times (161µs+0s) by Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:389] at line 336, avg 3µs/call sub _get_caller {
451 |  |  |  |  |
452 |  |  |  |  | # 1 extra level because it's called by import so there's a layer
453 |  |  |  |  | # of indirection
454 | 118 | 214µs |  |  | my $offset = 1;
455 |  |  |  |  |
456 |  |  |  |  | return
457 |  |  |  |  | ( ref $_[1] && defined $_[1]->{into} ) ? $_[1]->{into}
458 |  |  |  |  | : ( ref $_[1] && defined $_[1]->{into_level} )
459 |  |  |  |  | ? caller( $offset + $_[1]->{into_level} )
460 |  |  |  |  | : caller($offset);
461 |  |  |  |  | }
462 |  |  |  |  |
463 |  |  |  |  | # spent 35µs within Moose::Exporter::_make_unimport_sub which was called 5 times, avg 7µs/call: # 5 times (35µs+0s) by Moose::Exporter::build_import_methods at line 67, avg 7µs/call sub _make_unimport_sub {
464 | 30 | 37µs |  |  | shift;
465 |  |  |  |  | my $exporting_package = shift;
466 |  |  |  |  | my $exports = shift;
467 |  |  |  |  | my $export_recorder = shift;
468 |  |  |  |  | my $is_reexport = shift;
469 |  |  |  |  |
470 |  |  |  |  | # spent 3.24ms (318µs+2.92) within Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:478] which was called 31 times, avg 104µs/call: # once (17µs+111µs) by SimpleDB::Class::SQL::BEGIN@403 at line 403 of ../lib/SimpleDB/Class/SQL.pm # once (14µs+109µs) by SimpleDB::Class::Cache::BEGIN@448 at line 448 of ../lib/SimpleDB/Class/Cache.pm # once (15µs+105µs) by SimpleDB::Class::BEGIN@450 at line 450 of ../lib/SimpleDB/Class.pm # once (15µs+104µs) by SimpleDB::Client::BEGIN@339 at line 339 of SimpleDB/Client.pm # once (14µs+105µs) by SimpleDB::Class::Domain::BEGIN@458 at line 458 of ../lib/SimpleDB/Class/Domain.pm # once (12µs+106µs) by MooseX::AttributeHelpers::Trait::Counter::BEGIN@48 at line 48 of MooseX/AttributeHelpers/Trait/Counter.pm # once (9µs+109µs) by MooseX::AttributeHelpers::Trait::Collection::Array::BEGIN@22 at line 22 of MooseX/AttributeHelpers/Trait/Collection/Array.pm # once (12µs+104µs) by MooseX::ClassAttribute::Meta::Method::Accessor::BEGIN@120 at line 120 of MooseX/ClassAttribute/Meta/Method/Accessor.pm # once (10µs+103µs) by MooseX::AttributeHelpers::Trait::Bool::BEGIN@35 at line 35 of MooseX/AttributeHelpers/Trait/Bool.pm # once (15µs+96µs) by MooseX::AttributeHelpers::Trait::Number::BEGIN@56 at line 56 of MooseX/AttributeHelpers/Trait/Number.pm # once (7µs+103µs) by MooseX::AttributeHelpers::Trait::Collection::BEGIN@11 at line 11 of MooseX/AttributeHelpers/Trait/Collection.pm # once (8µs+99µs) by MooseX::AttributeHelpers::Trait::Collection::Hash::BEGIN@22 at line 22 of MooseX/AttributeHelpers/Trait/Collection/Hash.pm # once (12µs+94µs) by MooseX::AttributeHelpers::Collection::ImmutableHash::BEGIN@12 at line 12 of MooseX/AttributeHelpers/Collection/ImmutableHash.pm # once (8µs+98µs) by MooseX::AttributeHelpers::Trait::Collection::Bag::BEGIN@36 at line 36 of MooseX/AttributeHelpers/Trait/Collection/Bag.pm # once (8µs+97µs) by MooseX::AttributeHelpers::Trait::Collection::List::BEGIN@22 at line 22 of MooseX/AttributeHelpers/Trait/Collection/List.pm # once (6µs+99µs) by MooseX::AttributeHelpers::Trait::Collection::ImmutableHash::BEGIN@22 at line 22 of MooseX/AttributeHelpers/Trait/Collection/ImmutableHash.pm # once (9µs+95µs) by MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@138 at line 138 of MooseX/ClassAttribute/Role/Meta/Attribute.pm # once (15µs+89µs) by MooseX::AttributeHelpers::Collection::List::BEGIN@12 at line 12 of MooseX/AttributeHelpers/Collection/List.pm # once (11µs+88µs) by SimpleDB::Class::ResultSet::BEGIN@520 at line 520 of ../lib/SimpleDB/Class/ResultSet.pm # once (9µs+90µs) by MooseX::AttributeHelpers::Collection::Hash::BEGIN@12 at line 12 of MooseX/AttributeHelpers/Collection/Hash.pm # once (7µs+91µs) by MooseX::ClassAttribute::Role::Meta::Class::BEGIN@246 at line 246 of MooseX/ClassAttribute/Role/Meta/Class.pm # once (10µs+85µs) by MooseX::AttributeHelpers::Number::BEGIN@11 at line 11 of MooseX/AttributeHelpers/Number.pm # once (9µs+87µs) by MooseX::AttributeHelpers::Collection::Array::BEGIN@12 at line 12 of MooseX/AttributeHelpers/Collection/Array.pm # once (11µs+84µs) by MooseX::AttributeHelpers::Trait::Collection::Bag::BEGIN@37 at line 37 of MooseX/AttributeHelpers/Trait/Collection/Bag.pm # once (8µs+86µs) by MooseX::AttributeHelpers::Collection::Bag::BEGIN@12 at line 12 of MooseX/AttributeHelpers/Collection/Bag.pm # once (8µs+86µs) by MooseX::AttributeHelpers::Trait::String::BEGIN@48 at line 48 of MooseX/AttributeHelpers/Trait/String.pm # once (7µs+81µs) by MooseX::AttributeHelpers::Trait::Base::BEGIN@219 at line 219 of MooseX/AttributeHelpers/Trait/Base.pm # once (8µs+80µs) by MooseX::AttributeHelpers::Counter::BEGIN@12 at line 12 of MooseX/AttributeHelpers/Counter.pm # once (8µs+80µs) by MooseX::AttributeHelpers::Bool::BEGIN@11 at line 11 of MooseX/AttributeHelpers/Bool.pm # once (8µs+79µs) by MooseX::AttributeHelpers::String::BEGIN@12 at line 12 of MooseX/AttributeHelpers/String.pm # once (9µs+76µs) by MooseX::AttributeHelpers::Trait::Base::BEGIN@220 at line 220 of MooseX/AttributeHelpers/Trait/Base.pm return sub {
471 | 62 | 309µs |  |  | my $caller = scalar caller();
472 |  |  |  |  | Moose::Exporter->_remove_keywords(
473 |  |  |  |  | $caller,
474 |  |  |  |  | [ keys %{$exports} ], # spent 2.92ms making 31 calls to Moose::Exporter::_remove_keywords, avg 94µs/call
475 |  |  |  |  | $export_recorder,
476 |  |  |  |  | $is_reexport,
477 |  |  |  |  | );
478 |  |  |  |  | };
479 |  |  |  |  | }
480 |  |  |  |  |
481 |  |  |  |  | # spent 2.92ms (2.86+61µs) within Moose::Exporter::_remove_keywords which was called 31 times, avg 94µs/call: # 31 times (2.86ms+61µs) by Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:478] at line 474, avg 94µs/call sub _remove_keywords {
482 | 186 | 170µs |  |  | shift;
483 |  |  |  |  | my $package = shift;
484 |  |  |  |  | my $keywords = shift;
485 |  |  |  |  | my $recorded_exports = shift;
486 |  |  |  |  | my $is_reexport = shift;
487 |  |  |  |  |
488 | 3 | 84µs | 2 | 44µs | # spent 26µs (8+18) within Moose::Exporter::BEGIN@488 which was called # once (8µs+18µs) by Moose::BEGIN@14 at line 488 no strict 'refs'; # spent 26µs making 1 call to Moose::Exporter::BEGIN@488 # spent 18µs making 1 call to strict::unimport
489 |  |  |  |  |
490 |  |  |  |  | foreach my $name ( @{$keywords} ) {
491 | 2040 | 2.18ms |  |  | if ( defined &{ $package . '::' . $name } ) {
492 |  |  |  |  | my $sub = \&{ $package . '::' . $name };
493 |  |  |  |  |
494 |  |  |  |  | # make sure it is from us
495 |  |  |  |  | next unless $recorded_exports->{$sub};
496 |  |  |  |  |
497 | 58 | 294µs |  |  | if ( $is_reexport->{$name} ) {
498 | 3 | 300µs | 2 | 36µs | # spent 22µs (8+14) within Moose::Exporter::BEGIN@498 which was called # once (8µs+14µs) by Moose::BEGIN@14 at line 498 no strict 'refs'; # spent 22µs making 1 call to Moose::Exporter::BEGIN@498 # spent 14µs making 1 call to strict::unimport
499 |  |  |  |  | next
500 |  |  |  |  | unless _export_is_flagged(
501 |  |  |  |  | \*{ join q{::} => $package, $name } ); # spent 61µs making 58 calls to Moose::Exporter::_export_is_flagged, avg 1µs/call
502 |  |  |  |  | }
503 |  |  |  |  |
504 |  |  |  |  | # and if it is from us, then undef the slot
505 |  |  |  |  | delete ${ $package . '::' }{$name};
506 |  |  |  |  | }
507 |  |  |  |  | }
508 |  |  |  |  | }
509 |  |  |  |  |
510 |  |  |  |  | # spent 91µs within Moose::Exporter::_make_init_meta which was called 5 times, avg 18µs/call: # 5 times (91µs+0s) by Moose::Exporter::build_import_methods at line 74, avg 18µs/call sub _make_init_meta {
511 | 45 | 72µs |  |  | shift;
512 |  |  |  |  | my $class = shift;
513 |  |  |  |  | my $args = shift;
514 |  |  |  |  |
515 |  |  |  |  | my %old_style_roles;
516 |  |  |  |  | for my $role (
517 |  |  |  |  | map {"${_}_roles"}
518 |  |  |  |  | qw(
519 |  |  |  |  | metaclass
520 |  |  |  |  | attribute_metaclass
521 |  |  |  |  | method_metaclass
522 |  |  |  |  | wrapped_method_metaclass
523 |  |  |  |  | instance_metaclass
524 |  |  |  |  | constructor_class
525 |  |  |  |  | destructor_class
526 |  |  |  |  | error_class
527 |  |  |  |  | )
528 |  |  |  |  | ) {
529 | 40 | 10µs |  |  | $old_style_roles{$role} = $args->{$role}
530 |  |  |  |  | if exists $args->{$role};
531 |  |  |  |  | }
532 |  |  |  |  |
533 |  |  |  |  | my %base_class_roles;
534 |  |  |  |  | %base_class_roles = ( roles => $args->{base_class_roles} )
535 |  |  |  |  | if exists $args->{base_class_roles};
536 |  |  |  |  |
537 |  |  |  |  | my %new_style_roles = map { $_ => $args->{$_} }
538 |  |  |  |  | grep { exists $args->{$_} } qw( class_metaroles role_metaroles );
539 |  |  |  |  |
540 |  |  |  |  | return unless %new_style_roles || %old_style_roles || %base_class_roles;
541 |  |  |  |  |
542 |  |  |  |  | return sub {
543 |  |  |  |  | shift;
544 |  |  |  |  | my %options = @_;
545 |  |  |  |  |
546 |  |  |  |  | return unless Class::MOP::class_of( $options{for_class} );
547 |  |  |  |  |
548 |  |  |  |  | Moose::Util::MetaRole::apply_metaroles(
549 |  |  |  |  | for => $options{for_class},
550 |  |  |  |  | %new_style_roles,
551 |  |  |  |  | %old_style_roles,
552 |  |  |  |  | );
553 |  |  |  |  |
554 |  |  |  |  | Moose::Util::MetaRole::apply_base_class_roles(
555 |  |  |  |  | for_class => $options{for_class},
556 |  |  |  |  | %base_class_roles,
557 |  |  |  |  | )
558 |  |  |  |  | if Class::MOP::class_of( $options{for_class} )
559 |  |  |  |  | ->isa('Moose::Meta::Class');
560 |  |  |  |  |
561 |  |  |  |  | return Class::MOP::class_of( $options{for_class} );
562 |  |  |  |  | };
563 |  |  |  |  | }
564 |  |  |  |  |
565 |  |  |  |  | # spent 102µs (43+59) within Moose::Exporter::import which was called 5 times, avg 20µs/call: # once (9µs+15µs) by Moose::BEGIN@14 at line 14 of Moose.pm # once (9µs+12µs) by MooseX::ClassAttribute::BEGIN@10 at line 10 of MooseX/ClassAttribute.pm # once (9µs+11µs) by MooseX::Types::CheckedUtilExports::BEGIN@13 at line 13 of MooseX/Types/CheckedUtilExports.pm # once (8µs+12µs) by Moose::Role::BEGIN@17 at line 17 of Moose/Role.pm # once (8µs+10µs) by Moose::Util::TypeConstraints::BEGIN@7 at line 7 of Moose/Util/TypeConstraints.pm sub import {
566 | 10 | 26µs | 5 | 10µs | strict->import; # spent 10µs making 5 calls to strict::import, avg 2µs/call
567 |  |  |  |  | warnings->import; # spent 50µs making 5 calls to warnings::import, avg 10µs/call
568 |  |  |  |  | }
569 |  |  |  |  |
570 | 1 | 9µs |  |  | 1;
571 |  |  |  |  |
572 |  |  |  |  | __END__
573 |  |  |  |  |
574 |  |  |  |  | =head1 NAME
575 |  |  |  |  |
576 |  |  |  |  | Moose::Exporter - make an import() and unimport() just like Moose.pm
577 |  |  |  |  |
578 |  |  |  |  | =head1 SYNOPSIS
579 |  |  |  |  |
580 |  |  |  |  | package MyApp::Moose;
581 |  |  |  |  |
582 |  |  |  |  | use Moose ();
583 |  |  |  |  | use Moose::Exporter;
584 |  |  |  |  |
585 |  |  |  |  | Moose::Exporter->setup_import_methods(
586 |  |  |  |  | with_meta => [ 'has_rw', 'sugar2' ],
587 |  |  |  |  | as_is => [ 'sugar3', \&Some::Random::thing ],
588 |  |  |  |  | also => 'Moose',
589 |  |  |  |  | );
590 |  |  |  |  |
591 |  |  |  |  | sub has_rw {
592 |  |  |  |  | my ( $meta, $name, %options ) = @_;
593 |  |  |  |  | $meta->add_attribute(
594 |  |  |  |  | $name,
595 |  |  |  |  | is => 'rw',
596 |  |  |  |  | %options,
597 |  |  |  |  | );
598 |  |  |  |  | }
599 |  |  |  |  |
600 |  |  |  |  | # then later ...
601 |  |  |  |  | package MyApp::User;
602 |  |  |  |  |
603 |  |  |  |  | use MyApp::Moose;
604 |  |  |  |  |
605 |  |  |  |  | has 'name';
606 |  |  |  |  | has_rw 'size';
607 |  |  |  |  | thing;
608 |  |  |  |  |
609 |  |  |  |  | no MyApp::Moose;
610 |  |  |  |  |
611 |  |  |  |  | =head1 DESCRIPTION
612 |  |  |  |  |
613 |  |  |  |  | This module encapsulates the exporting of sugar functions in a
614 |  |  |  |  | C<Moose.pm>-like manner. It does this by building custom C<import>,
615 |  |  |  |  | C<unimport>, and C<init_meta> methods for your module, based on a spec you
616 |  |  |  |  | provide.
617 |  |  |  |  |
618 |  |  |  |  | It also lets you "stack" Moose-alike modules so you can export Moose's sugar
619 |  |  |  |  | as well as your own, along with sugar from any random C<MooseX> module, as
620 |  |  |  |  | long as they all use C<Moose::Exporter>. This feature exists to let you bundle
621 |  |  |  |  | a set of MooseX modules into a policy module that developers can use directly
622 |  |  |  |  | instead of using Moose itself.
623 |  |  |  |  |
624 |  |  |  |  | To simplify writing exporter modules, C<Moose::Exporter> also imports
625 |  |  |  |  | C<strict> and C<warnings> into your exporter module, as well as into
626 |  |  |  |  | modules that use it.
627 |  |  |  |  |
628 |  |  |  |  | =head1 METHODS
629 |  |  |  |  |
630 |  |  |  |  | This module provides two public methods:
631 |  |  |  |  |
632 |  |  |  |  | =over 4
633 |  |  |  |  |
634 |  |  |  |  | =item B<< Moose::Exporter->setup_import_methods(...) >>
635 |  |  |  |  |
636 |  |  |  |  | When you call this method, C<Moose::Exporter> builds custom C<import>,
637 |  |  |  |  | C<unimport>, and C<init_meta> methods for your module. The C<import> method
638 |  |  |  |  | will export the functions you specify, and can also re-export functions
639 |  |  |  |  | exported by some other module (like C<Moose.pm>).
640 |  |  |  |  |
641 |  |  |  |  | The C<unimport> method cleans the caller's namespace of all the exported
642 |  |  |  |  | functions. This includes any functions you re-export from other
643 |  |  |  |  | packages. However, if the consumer of your package also imports those
644 |  |  |  |  | functions from the original package, they will I<not> be cleaned.
645 |  |  |  |  |
646 |  |  |  |  | If you pass any parameters for L<Moose::Util::MetaRole>, this method will
647 |  |  |  |  | generate an C<init_meta> for you as well (see below for details). This
648 |  |  |  |  | C<init_meta> will call C<Moose::Util::MetaRole::apply_metaclass_roles> and
649 |  |  |  |  | C<Moose::Util::MetaRole::apply_base_class_roles> as needed.
650 |  |  |  |  |
651 |  |  |  |  | Note that if any of these methods already exist, they will not be
652 |  |  |  |  | overridden, you will have to use C<build_import_methods> to get the
653 |  |  |  |  | coderef that would be installed.
654 |  |  |  |  |
655 |  |  |  |  | This method accepts the following parameters:
656 |  |  |  |  |
657 |  |  |  |  | =over 8
658 |  |  |  |  |
659 |  |  |  |  | =item * with_meta => [ ... ]
660 |  |  |  |  |
661 |  |  |  |  | This list of function I<names only> will be wrapped and then exported. The
662 |  |  |  |  | wrapper will pass the metaclass object for the caller as its first argument.
663 |  |  |  |  |
664 |  |  |  |  | Many sugar functions will need to use this metaclass object to do something to
665 |  |  |  |  | the calling package.
666 |  |  |  |  |
667 |  |  |  |  | =item * as_is => [ ... ]
668 |  |  |  |  |
669 |  |  |  |  | This list of function names or sub references will be exported as-is. You can
670 |  |  |  |  | identify a subroutine by reference, which is handy to re-export some other
671 |  |  |  |  | module's functions directly by reference (C<\&Some::Package::function>).
672 |  |  |  |  |
673 |  |  |  |  | If you do export some other package's function, this function will never be
674 |  |  |  |  | removed by the C<unimport> method. The reason for this is we cannot know if
675 |  |  |  |  | the caller I<also> explicitly imported the sub themselves, and therefore wants
676 |  |  |  |  | to keep it.
677 |  |  |  |  |
678 |  |  |  |  | =item * also => $name or \@names
679 |  |  |  |  |
680 |  |  |  |  | This is a list of modules which contain functions that the caller
681 |  |  |  |  | wants to export. These modules must also use C<Moose::Exporter>. The
682 |  |  |  |  | most common use case will be to export the functions from C<Moose.pm>.
683 |  |  |  |  | Functions specified by C<with_meta> or C<as_is> take precedence over
684 |  |  |  |  | functions exported by modules specified by C<also>, so that a module
685 |  |  |  |  | can selectively override functions exported by another module.
686 |  |  |  |  |
687 |  |  |  |  | C<Moose::Exporter> also makes sure all these functions get removed
688 |  |  |  |  | when C<unimport> is called.
689 |  |  |  |  |
690 |  |  |  |  | =back
691 |  |  |  |  |
692 |  |  |  |  | You can also provide parameters for C<Moose::Util::MetaRole::apply_metaroles>
693 |  |  |  |  | and C<Moose::Util::MetaRole::base_class_roles>. Specifically, valid parameters
694 |  |  |  |  | are "class_metaroles", "role_metaroles", and "base_object_roles".
695 |  |  |  |  |
696 |  |  |  |  | =item B<< Moose::Exporter->build_import_methods(...) >>
697 |  |  |  |  |
698 |  |  |  |  | Returns two or three code refs, one for C<import>, one for
699 |  |  |  |  | C<unimport>, and optionally one for C<init_meta>, if the appropriate
700 |  |  |  |  | options are passed in.
701 |  |  |  |  |
702 |  |  |  |  | Accepts the additional C<install> option, which accepts an arrayref of method
703 |  |  |  |  | names to install into your exporting package. The valid options are C<import>,
704 |  |  |  |  | C<unimport>, and C<init_meta>. Calling C<setup_import_methods> is equivalent
705 |  |  |  |  | to calling C<build_import_methods> with C<< install => [qw(import unimport
706 |  |  |  |  | init_meta)] >> except that it doesn't also return the methods.
707 |  |  |  |  |
708 |  |  |  |  | Used by C<setup_import_methods>.
709 |  |  |  |  |
710 |  |  |  |  | =back
711 |  |  |  |  |
712 |  |  |  |  | =head1 IMPORTING AND init_meta
713 |  |  |  |  |
714 |  |  |  |  | If you want to set an alternative base object class or metaclass class, see
715 |  |  |  |  | above for details on how this module can call L<Moose::Util::MetaRole> for
716 |  |  |  |  | you.
717 |  |  |  |  |
718 |  |  |  |  | If you want to do something that is not supported by this module, simply
719 |  |  |  |  | define an C<init_meta> method in your class. The C<import> method that
720 |  |  |  |  | C<Moose::Exporter> generates for you will call this method (if it exists). It
721 |  |  |  |  | will always pass the caller to this method via the C<for_class> parameter.
722 |  |  |  |  |
723 |  |  |  |  | Most of the time, your C<init_meta> method will probably just call C<<
724 |  |  |  |  | Moose->init_meta >> to do the real work:
725 |  |  |  |  |
726 |  |  |  |  | sub init_meta {
727 |  |  |  |  | shift; # our class name
728 |  |  |  |  | return Moose->init_meta( @_, metaclass => 'My::Metaclass' );
729 |  |  |  |  | }
730 |  |  |  |  |
731 |  |  |  |  | Keep in mind that C<build_import_methods> will return an C<init_meta>
732 |  |  |  |  | method for you, which you can also call from within your custom
733 |  |  |  |  | C<init_meta>:
734 |  |  |  |  |
735 |  |  |  |  | my ( $import, $unimport, $init_meta ) =
736 |  |  |  |  | Moose::Exporter->build_import_methods( ... );
737 |  |  |  |  |
738 |  |  |  |  | sub import {
739 |  |  |  |  | my $class = shift;
740 |  |  |  |  |
741 |  |  |  |  | ...
742 |  |  |  |  |
743 |  |  |  |  | $class->$import(...);
744 |  |  |  |  |
745 |  |  |  |  | ...
746 |  |  |  |  | }
747 |  |  |  |  |
748 |  |  |  |  | sub unimport { goto &$unimport }
749 |  |  |  |  |
750 |  |  |  |  | sub init_meta {
751 |  |  |  |  | my $class = shift;
752 |  |  |  |  |
753 |  |  |  |  | ...
754 |  |  |  |  |
755 |  |  |  |  | $class->$init_meta(...);
756 |  |  |  |  |
757 |  |  |  |  | ...
758 |  |  |  |  | }
759 |  |  |  |  |
760 |  |  |  |  | =head1 METACLASS TRAITS
761 |  |  |  |  |
762 |  |  |  |  | The C<import> method generated by C<Moose::Exporter> will allow the
763 |  |  |  |  | user of your module to specify metaclass traits in a C<-traits>
764 |  |  |  |  | parameter passed as part of the import:
765 |  |  |  |  |
766 |  |  |  |  | use Moose -traits => 'My::Meta::Trait';
767 |  |  |  |  |
768 |  |  |  |  | use Moose -traits => [ 'My::Meta::Trait', 'My::Other::Trait' ];
769 |  |  |  |  |
770 |  |  |  |  | These traits will be applied to the caller's metaclass
771 |  |  |  |  | instance. Providing traits for an exporting class that does not create
772 |  |  |  |  | a metaclass for the caller is an error.
773 |  |  |  |  |
774 |  |  |  |  | =head1 BUGS
775 |  |  |  |  |
776 |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs.
777 |  |  |  |  |
778 |  |  |  |  | =head1 AUTHOR
779 |  |  |  |  |
780 |  |  |  |  | Dave Rolsky E<lt>autarch@urth.orgE<gt>
781 |  |  |  |  |
782 |  |  |  |  | This is largely a reworking of code in Moose.pm originally written by
783 |  |  |  |  | Stevan Little and others.
784 |  |  |  |  |
785 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
786 |  |  |  |  |
787 |  |  |  |  | Copyright 2009 by Infinity Interactive, Inc.
788 |  |  |  |  |
789 |  |  |  |  | L<http://www.iinteractive.com>
790 |  |  |  |  |
791 |  |  |  |  | This library is free software; you can redistribute it and/or modify
792 |  |  |  |  | it under the same terms as Perl itself.
793 |  |  |  |  |
794 |  |  |  |  | =cut
|  |  |  |  | # spent 61µs within Moose::Exporter::_export_is_flagged which was called 58 times, avg 1µs/call: # 58 times (61µs+0s) by Moose::Exporter::_remove_keywords at line 501 of Moose/Exporter.pm, avg 1µs/call sub Moose::Exporter::_export_is_flagged; # xsub
|  |  |  |  | # spent 97µs within Moose::Exporter::_flag_as_reexport which was called 96 times, avg 1µs/call: # 96 times (97µs+0s) by Moose::Exporter::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Exporter.pm:389] at line 387 of Moose/Exporter.pm, avg 1µs/call sub Moose::Exporter::_flag_as_reexport; # xsub