Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm |
Statements | Executed 1024 statements in 3.39ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.40ms | 64.2ms | BEGIN@8 | Moose::Exporter::
1 | 1 | 1 | 647µs | 5.25ms | BEGIN@9 | Moose::Exporter::
1 | 1 | 1 | 490µs | 4.63ms | BEGIN@10 | Moose::Exporter::
2 | 1 | 1 | 162µs | 238µs | _make_sub_exporter_params | Moose::Exporter::
2 | 1 | 1 | 98µs | 1.18ms | build_import_methods | Moose::Exporter::
8 | 5 | 2 | 71µs | 26.4ms | has | Moose::
2 | 1 | 1 | 56µs | 315µs | __ANON__[:140] | Moose::Exporter::
30 | 3 | 1 | 51µs | 51µs | _sub_from_package | Moose::Exporter::
1 | 1 | 1 | 45µs | 46µs | _remove_keywords | Moose::Exporter::
8 | 1 | 1 | 39µs | 79µs | __ANON__[:389] | Moose::Exporter::
2 | 1 | 1 | 32µs | 32µs | _collect_metaroles | Moose::Exporter::
4 | 1 | 1 | 23µs | 39µs | __ANON__[:252] | Moose::Exporter::
2 | 1 | 1 | 22µs | 22µs | _make_init_meta | Moose::Exporter::
8 | 1 | 1 | 22µs | 22µs | _late_curry_wrapper | Moose::Exporter::
22 | 1 | 1 | 21µs | 21µs | __ANON__[:317] | Moose::Exporter::
2 | 1 | 1 | 19µs | 59µs | _follow_also | Moose::Exporter::
2 | 1 | 1 | 18µs | 64µs | _apply_metaroles | Moose::Exporter::
2 | 1 | 1 | 18µs | 595µs | _make_exporter | Moose::Exporter::
2 | 2 | 2 | 17µs | 1.20ms | setup_import_methods | Moose::Exporter::
2 | 1 | 1 | 17µs | 29µs | _strip_traits | Moose::Exporter::
2 | 1 | 1 | 17µs | 27µs | _die_if_cycle_found_in_also_list_for_package | Moose::Exporter::
2 | 2 | 2 | 13µs | 27µs | import | Moose::Exporter::
1 | 1 | 1 | 12µs | 36µs | BEGIN@11 | Moose::Exporter::
8 | 1 | 1 | 12µs | 12µs | _make_wrapped_sub_with_meta | Moose::Exporter::
4 | 2 | 1 | 10µs | 21µs | __ANON__[:39] | Moose::Exporter::
1 | 1 | 1 | 9µs | 11µs | BEGIN@4 | Moose::Exporter::
2 | 1 | 1 | 9µs | 9µs | _make_import_sub | Moose::Exporter::
2 | 1 | 1 | 9µs | 9µs | _make_unimport_sub | Moose::Exporter::
2 | 1 | 1 | 9µs | 11µs | _strip_meta_name | Moose::Exporter::
1 | 1 | 1 | 9µs | 73µs | BEGIN@12 | Moose::Exporter::
2 | 1 | 1 | 9µs | 11µs | _strip_metaclass | Moose::Exporter::
1 | 1 | 1 | 7µs | 19µs | BEGIN@135 | Moose::Exporter::
2 | 1 | 1 | 7µs | 7µs | _parse_trait_aliases | Moose::Exporter::
1 | 1 | 1 | 7µs | 15µs | BEGIN@331 | Moose::Exporter::
22 | 1 | 1 | 7µs | 7µs | CORE:match (opcode) | Moose::Exporter::
1 | 1 | 1 | 6µs | 30µs | BEGIN@7 | Moose::Exporter::
2 | 1 | 1 | 6µs | 8µs | _follow_also_real | Moose::Exporter::
4 | 2 | 1 | 6µs | 6µs | _also_list_for_package | Moose::Exporter::
2 | 1 | 1 | 6µs | 6µs | _get_caller | Moose::Exporter::
1 | 1 | 1 | 6µs | 21µs | BEGIN@13 | Moose::Exporter::
1 | 1 | 1 | 6µs | 15µs | BEGIN@725 | Moose::Exporter::
1 | 1 | 1 | 5µs | 18µs | BEGIN@136 | Moose::Exporter::
1 | 1 | 1 | 5µs | 12µs | BEGIN@5 | Moose::Exporter::
2 | 1 | 1 | 5µs | 5µs | _die_if_also_list_cycles_back_to_existing_stack | Moose::Exporter::
1 | 1 | 1 | 4µs | 10µs | BEGIN@735 | Moose::Exporter::
1 | 1 | 1 | 4µs | 76µs | BEGIN@15 | Moose::Exporter::
2 | 1 | 1 | 2µs | 2µs | _flag_as_reexport (xsub) | Moose::Exporter::
2 | 1 | 1 | 900ns | 900ns | _export_is_flagged (xsub) | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:228] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:366] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:398] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:420] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:528] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:532] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:546] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:558] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:715] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:787] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | _apply_meta_traits | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | _curry_wrapper | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | _make_wrapped_sub | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | after | Moose::
0 | 0 | 0 | 0s | 0s | around | Moose::
0 | 0 | 0 | 0s | 0s | augment | Moose::
0 | 0 | 0 | 0s | 0s | before | Moose::
0 | 0 | 0 | 0s | 0s | extends | Moose::
0 | 0 | 0 | 0s | 0s | override | Moose::
0 | 0 | 0 | 0s | 0s | with | Moose::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Exporter; | ||||
2 | 1 | 500ns | our $VERSION = '2.1605'; | ||
3 | |||||
4 | 2 | 15µs | 2 | 13µs | # spent 11µs (9+2) within Moose::Exporter::BEGIN@4 which was called:
# once (9µs+2µs) by Moose::BEGIN@15 at line 4 # spent 11µs making 1 call to Moose::Exporter::BEGIN@4
# spent 2µs making 1 call to strict::import |
5 | 2 | 16µs | 2 | 19µs | # spent 12µs (5+7) within Moose::Exporter::BEGIN@5 which was called:
# once (5µs+7µs) by Moose::BEGIN@15 at line 5 # spent 12µs making 1 call to Moose::Exporter::BEGIN@5
# spent 7µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 15µs | 2 | 54µs | # spent 30µs (6+24) within Moose::Exporter::BEGIN@7 which was called:
# once (6µs+24µs) by Moose::BEGIN@15 at line 7 # spent 30µs making 1 call to Moose::Exporter::BEGIN@7
# spent 24µs making 1 call to Exporter::import |
8 | 2 | 138µs | 1 | 64.2ms | # spent 64.2ms (2.40+61.8) within Moose::Exporter::BEGIN@8 which was called:
# once (2.40ms+61.8ms) by Moose::BEGIN@15 at line 8 # spent 64.2ms making 1 call to Moose::Exporter::BEGIN@8 |
9 | 2 | 101µs | 2 | 5.57ms | # spent 5.25ms (647µs+4.60) within Moose::Exporter::BEGIN@9 which was called:
# once (647µs+4.60ms) by Moose::BEGIN@15 at line 9 # spent 5.25ms making 1 call to Moose::Exporter::BEGIN@9
# spent 324µs making 1 call to Exporter::Tiny::import |
10 | 2 | 122µs | 1 | 4.63ms | # spent 4.63ms (490µs+4.14) within Moose::Exporter::BEGIN@10 which was called:
# once (490µs+4.14ms) by Moose::BEGIN@15 at line 10 # spent 4.63ms making 1 call to Moose::Exporter::BEGIN@10 |
11 | 3 | 32µs | 3 | 60µs | # spent 36µs (12+24) within Moose::Exporter::BEGIN@11 which was called:
# once (12µs+24µs) by Moose::BEGIN@15 at line 11 # spent 36µs making 1 call to Moose::Exporter::BEGIN@11
# spent 18µs making 1 call to Exporter::import
# spent 6µs making 1 call to UNIVERSAL::VERSION |
12 | 3 | 28µs | 3 | 136µs | # spent 73µs (9+64) within Moose::Exporter::BEGIN@12 which was called:
# once (9µs+64µs) by Moose::BEGIN@15 at line 12 # spent 73µs making 1 call to Moose::Exporter::BEGIN@12
# spent 59µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
# spent 4µs making 1 call to UNIVERSAL::VERSION |
13 | 2 | 18µs | 2 | 37µs | # spent 21µs (6+15) within Moose::Exporter::BEGIN@13 which was called:
# once (6µs+15µs) by Moose::BEGIN@15 at line 13 # spent 21µs making 1 call to Moose::Exporter::BEGIN@13
# spent 15µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 280µs | 2 | 148µs | # spent 76µs (4+72) within Moose::Exporter::BEGIN@15 which was called:
# once (4µs+72µs) by Moose::BEGIN@15 at line 15 # spent 76µs making 1 call to Moose::Exporter::BEGIN@15
# spent 72µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
16 | |||||
17 | 1 | 200ns | my %EXPORT_SPEC; | ||
18 | |||||
19 | # spent 1.20ms (17µs+1.18) within Moose::Exporter::setup_import_methods which was called 2 times, avg 599µs/call:
# once (9µs+613µs) by Moose::Meta::Attribute::BEGIN@16 at line 38 of Moose/Util/TypeConstraints.pm
# once (8µs+569µs) by DBIx::MultiStatementDo::BEGIN@8 at line 132 of Moose.pm | ||||
20 | 2 | 3µs | my ( $class, %args ) = @_; | ||
21 | |||||
22 | 2 | 3µs | $args{exporting_package} ||= caller(); | ||
23 | |||||
24 | 2 | 11µs | 2 | 1.18ms | $class->build_import_methods( # spent 1.18ms making 2 calls to Moose::Exporter::build_import_methods, avg 591µs/call |
25 | %args, | ||||
26 | install => [qw(import unimport init_meta)] | ||||
27 | ); | ||||
28 | } | ||||
29 | |||||
30 | # A reminder to intrepid Moose hackers | ||||
31 | # there may be more than one level of exporter | ||||
32 | # don't make doy cry. -- perigrin | ||||
33 | |||||
34 | # spent 1.18ms (98µs+1.08) within Moose::Exporter::build_import_methods which was called 2 times, avg 591µs/call:
# 2 times (98µs+1.08ms) by Moose::Exporter::setup_import_methods at line 24, avg 591µs/call | ||||
35 | 2 | 2µs | my ( $class, %args ) = @_; | ||
36 | |||||
37 | 2 | 1µs | my $exporting_package = $args{exporting_package} ||= caller(); | ||
38 | |||||
39 | 6 | 15µs | 4 | 11µs | # spent 21µs (10+11) within Moose::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm:39] which was called 4 times, avg 5µs/call:
# 2 times (6µs+6µs) by Moose::Exporter::_apply_metaroles at line 575, avg 6µs/call
# 2 times (4µs+5µs) by Moose::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm:140] at line 111, avg 4µs/call # spent 11µs making 4 calls to Class::MOP::class_of, avg 3µs/call |
40 | |||||
41 | 2 | 2µs | $EXPORT_SPEC{$exporting_package} = \%args; | ||
42 | |||||
43 | 2 | 4µs | 2 | 59µs | my @exports_from = $class->_follow_also($exporting_package); # spent 59µs making 2 calls to Moose::Exporter::_follow_also, avg 29µs/call |
44 | |||||
45 | 2 | 1µs | my $export_recorder = {}; | ||
46 | 2 | 800ns | my $is_reexport = {}; | ||
47 | |||||
48 | my $exports = $class->_make_sub_exporter_params( | ||||
49 | [ $exporting_package, @exports_from ], | ||||
50 | $export_recorder, | ||||
51 | $is_reexport, | ||||
52 | $args{meta_lookup}, # so that we don't pass through the default | ||||
53 | 2 | 7µs | 2 | 238µs | ); # spent 238µs making 2 calls to Moose::Exporter::_make_sub_exporter_params, avg 119µs/call |
54 | |||||
55 | 2 | 4µs | 2 | 595µs | my $exporter = $class->_make_exporter( # spent 595µs making 2 calls to Moose::Exporter::_make_exporter, avg 297µs/call |
56 | $exports, | ||||
57 | $is_reexport, | ||||
58 | $meta_lookup, | ||||
59 | ); | ||||
60 | |||||
61 | 2 | 400ns | my %methods; | ||
62 | 2 | 6µs | 2 | 9µs | $methods{import} = $class->_make_import_sub( # spent 9µs making 2 calls to Moose::Exporter::_make_import_sub, avg 5µs/call |
63 | $exporting_package, | ||||
64 | $exporter, | ||||
65 | \@exports_from, | ||||
66 | $is_reexport, | ||||
67 | $meta_lookup, | ||||
68 | ); | ||||
69 | |||||
70 | 2 | 5µs | 2 | 9µs | $methods{unimport} = $class->_make_unimport_sub( # spent 9µs making 2 calls to Moose::Exporter::_make_unimport_sub, avg 5µs/call |
71 | $exporting_package, | ||||
72 | $exports, | ||||
73 | $export_recorder, | ||||
74 | $is_reexport, | ||||
75 | $meta_lookup, | ||||
76 | ); | ||||
77 | |||||
78 | 2 | 7µs | 2 | 22µs | $methods{init_meta} = $class->_make_init_meta( # spent 22µs making 2 calls to Moose::Exporter::_make_init_meta, avg 11µs/call |
79 | $exporting_package, | ||||
80 | \%args, | ||||
81 | $meta_lookup, | ||||
82 | ); | ||||
83 | |||||
84 | 2 | 5µs | 2 | 42µs | my $package = Class::MOP::Package->initialize($exporting_package); # spent 42µs making 2 calls to Class::MOP::Package::initialize, avg 21µs/call |
85 | 2 | 2µs | for my $to_install ( @{ $args{install} || [] } ) { | ||
86 | 6 | 4µs | my $symbol = '&' . $to_install; | ||
87 | |||||
88 | next | ||||
89 | 6 | 8µs | 4 | 57µs | unless $methods{$to_install} # spent 57µs making 4 calls to Class::MOP::Package::has_package_symbol, avg 14µs/call |
90 | && !$package->has_package_symbol($symbol); | ||||
91 | $package->add_package_symbol( | ||||
92 | $symbol, | ||||
93 | subname( | ||||
94 | 4 | 28µs | 8 | 52µs | $exporting_package . '::' . $to_install, $methods{$to_install} # spent 37µs making 4 calls to Class::MOP::Package::add_package_symbol, avg 9µs/call
# spent 15µs making 4 calls to Sub::Name::subname, avg 4µs/call |
95 | ) | ||||
96 | ); | ||||
97 | } | ||||
98 | |||||
99 | 2 | 6µs | return ( $methods{import}, $methods{unimport}, $methods{init_meta} ); | ||
100 | } | ||||
101 | |||||
102 | # spent 595µs (18+577) within Moose::Exporter::_make_exporter which was called 2 times, avg 297µs/call:
# 2 times (18µs+577µs) by Moose::Exporter::build_import_methods at line 55, avg 297µs/call | ||||
103 | 2 | 1µs | my ($class, $exports, $is_reexport, $meta_lookup) = @_; | ||
104 | |||||
105 | return Sub::Exporter::build_exporter( | ||||
106 | { | ||||
107 | exports => $exports, | ||||
108 | groups => { default => [':all'] }, | ||||
109 | # spent 315µs (56+259) within Moose::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm:140] which was called 2 times, avg 157µs/call:
# 2 times (56µs+259µs) by Sub::Exporter::_do_import at line 386 of Sub/Exporter.pm, avg 157µs/call | ||||
110 | 2 | 700ns | my ($arg, $to_export) = @_; | ||
111 | 2 | 2µs | 2 | 8µs | my $meta = $meta_lookup->($arg->{into}); # spent 8µs making 2 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:39], avg 4µs/call |
112 | |||||
113 | 2 | 4µs | 1 | 289µs | goto &Sub::Exporter::default_installer unless $meta; # spent 289µs making 1 call to Sub::Exporter::default_installer |
114 | |||||
115 | # don't overwrite existing symbols with our magically flagged | ||||
116 | # version of it if we would install the same sub that's already | ||||
117 | # in the importer | ||||
118 | |||||
119 | 1 | 300ns | my @filtered_to_export; | ||
120 | my %installed; | ||||
121 | 1 | 4µs | for (my $i = 0; $i < @{ $to_export }; $i += 2) { | ||
122 | 12 | 5µs | my ($as, $cv) = @{ $to_export }[$i, $i + 1]; | ||
123 | |||||
124 | 12 | 11µs | 12 | 47µs | next if !ref($as) # spent 47µs making 12 calls to Class::MOP::Package::has_package_symbol, avg 4µs/call |
125 | && $meta->has_package_symbol('&' . $as) | ||||
126 | && $meta->get_package_symbol('&' . $as) == $cv; | ||||
127 | |||||
128 | 12 | 3µs | push @filtered_to_export, $as, $cv; | ||
129 | 12 | 4µs | $installed{$as} = 1 unless ref $as; | ||
130 | } | ||||
131 | |||||
132 | 1 | 1µs | 1 | 201µs | Sub::Exporter::default_installer($arg, \@filtered_to_export); # spent 201µs making 1 call to Sub::Exporter::default_installer |
133 | |||||
134 | 1 | 6µs | for my $name ( keys %{$is_reexport} ) { | ||
135 | 2 | 18µs | 2 | 30µs | # spent 19µs (7+11) within Moose::Exporter::BEGIN@135 which was called:
# once (7µs+11µs) by Moose::BEGIN@15 at line 135 # spent 19µs making 1 call to Moose::Exporter::BEGIN@135
# spent 12µs making 1 call to strict::unimport |
136 | 2 | 545µs | 2 | 31µs | # spent 18µs (5+13) within Moose::Exporter::BEGIN@136 which was called:
# once (5µs+13µs) by Moose::BEGIN@15 at line 136 # spent 18µs making 1 call to Moose::Exporter::BEGIN@136
# spent 13µs making 1 call to warnings::unimport |
137 | 2 | 400ns | next unless exists $installed{$name}; | ||
138 | 2 | 9µs | 2 | 2µs | _flag_as_reexport( \*{ join q{::}, $arg->{into}, $name } ); # spent 2µs making 2 calls to Moose::Exporter::_flag_as_reexport, avg 1µs/call |
139 | } | ||||
140 | }, | ||||
141 | } | ||||
142 | 2 | 18µs | 2 | 577µs | ); # spent 577µs making 2 calls to Sub::Exporter::build_exporter, avg 288µs/call |
143 | } | ||||
144 | |||||
145 | # spent 59µs (19+39) within Moose::Exporter::_follow_also which was called 2 times, avg 29µs/call:
# 2 times (19µs+39µs) by Moose::Exporter::build_import_methods at line 43, avg 29µs/call | ||||
146 | 2 | 900ns | my $class = shift; | ||
147 | 2 | 500ns | my $exporting_package = shift; | ||
148 | |||||
149 | 2 | 3µs | 2 | 27µs | _die_if_cycle_found_in_also_list_for_package($exporting_package); # spent 27µs making 2 calls to Moose::Exporter::_die_if_cycle_found_in_also_list_for_package, avg 13µs/call |
150 | |||||
151 | 2 | 18µs | 4 | 13µs | return uniq( _follow_also_real($exporting_package) ); # spent 8µs making 2 calls to Moose::Exporter::_follow_also_real, avg 4µs/call
# spent 5µs making 2 calls to List::MoreUtils::uniq, avg 3µs/call |
152 | } | ||||
153 | |||||
154 | # spent 8µs (6+1) within Moose::Exporter::_follow_also_real which was called 2 times, avg 4µs/call:
# 2 times (6µs+1µs) by Moose::Exporter::_follow_also at line 151, avg 4µs/call | ||||
155 | 2 | 600ns | my $exporting_package = shift; | ||
156 | 2 | 2µs | 2 | 1µs | my @also = _also_list_for_package($exporting_package); # spent 1µs making 2 calls to Moose::Exporter::_also_list_for_package, avg 550ns/call |
157 | |||||
158 | 2 | 3µs | return map { $_, _follow_also_real($_) } @also; | ||
159 | } | ||||
160 | |||||
161 | sub _also_list_for_package { | ||||
162 | 4 | 700ns | my $package = shift; | ||
163 | |||||
164 | 4 | 1µs | if ( !exists $EXPORT_SPEC{$package} ) { | ||
165 | my $loaded = is_class_loaded($package); | ||||
166 | |||||
167 | throw_exception( PackageDoesNotUseMooseExporter => package => $package, | ||||
168 | is_loaded => $loaded | ||||
169 | ); | ||||
170 | } | ||||
171 | |||||
172 | 4 | 1µs | my $also = $EXPORT_SPEC{$package}{also}; | ||
173 | |||||
174 | 4 | 11µs | return unless defined $also; | ||
175 | |||||
176 | return ref $also ? @$also : $also; | ||||
177 | } | ||||
178 | |||||
179 | # this is no Tarjan algorithm, but for the list sizes expected, | ||||
180 | # brute force will probably be fine (and more maintainable) | ||||
181 | # spent 27µs (17+10) within Moose::Exporter::_die_if_cycle_found_in_also_list_for_package which was called 2 times, avg 13µs/call:
# 2 times (17µs+10µs) by Moose::Exporter::_follow_also at line 149, avg 13µs/call | ||||
182 | 2 | 2µs | my $package = shift; | ||
183 | 2 | 12µs | 4 | 10µs | _die_if_also_list_cycles_back_to_existing_stack( # spent 5µs making 2 calls to Moose::Exporter::_also_list_for_package, avg 3µs/call
# spent 5µs making 2 calls to Moose::Exporter::_die_if_also_list_cycles_back_to_existing_stack, avg 2µs/call |
184 | [ _also_list_for_package($package) ], | ||||
185 | [$package], | ||||
186 | ); | ||||
187 | } | ||||
188 | |||||
189 | # spent 5µs within Moose::Exporter::_die_if_also_list_cycles_back_to_existing_stack which was called 2 times, avg 2µs/call:
# 2 times (5µs+0s) by Moose::Exporter::_die_if_cycle_found_in_also_list_for_package at line 183, avg 2µs/call | ||||
190 | 2 | 900ns | my ( $also_list, $existing_stack ) = @_; | ||
191 | |||||
192 | 2 | 4µs | return unless @$also_list && @$existing_stack; | ||
193 | |||||
194 | for my $also_member (@$also_list) { | ||||
195 | for my $stack_member (@$existing_stack) { | ||||
196 | next unless $also_member eq $stack_member; | ||||
197 | |||||
198 | throw_exception( CircularReferenceInAlso => also_parameter => $also_member, | ||||
199 | stack => $existing_stack | ||||
200 | ); | ||||
201 | } | ||||
202 | |||||
203 | _die_if_also_list_cycles_back_to_existing_stack( | ||||
204 | [ _also_list_for_package($also_member) ], | ||||
205 | [ $also_member, @$existing_stack ], | ||||
206 | ); | ||||
207 | } | ||||
208 | } | ||||
209 | |||||
210 | # spent 7µs within Moose::Exporter::_parse_trait_aliases which was called 2 times, avg 4µs/call:
# 2 times (7µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 283, avg 4µs/call | ||||
211 | 2 | 600ns | my $class = shift; | ||
212 | 2 | 1µs | my ($package, $aliases) = @_; | ||
213 | |||||
214 | 2 | 400ns | my @ret; | ||
215 | 2 | 3µs | for my $alias (@$aliases) { | ||
216 | my $name; | ||||
217 | if (ref($alias)) { | ||||
218 | reftype($alias) eq 'ARRAY' | ||||
219 | or throw_exception( InvalidArgumentsToTraitAliases => class_name => $class, | ||||
220 | package_name => $package, | ||||
221 | alias => $alias | ||||
222 | ); | ||||
223 | ($alias, $name) = @$alias; | ||||
224 | } | ||||
225 | else { | ||||
226 | ($name = $alias) =~ s/.*:://; | ||||
227 | } | ||||
228 | push @ret, subname "${package}::${name}" => sub () { $alias }; | ||||
229 | } | ||||
230 | |||||
231 | 2 | 6µs | return @ret; | ||
232 | } | ||||
233 | |||||
234 | # spent 238µs (162+76) within Moose::Exporter::_make_sub_exporter_params which was called 2 times, avg 119µs/call:
# 2 times (162µs+76µs) by Moose::Exporter::build_import_methods at line 53, avg 119µs/call | ||||
235 | 2 | 500ns | my $class = shift; | ||
236 | 2 | 500ns | my $packages = shift; | ||
237 | 2 | 500ns | my $export_recorder = shift; | ||
238 | 2 | 400ns | my $is_reexport = shift; | ||
239 | 2 | 2µs | my $meta_lookup_override = shift; | ||
240 | |||||
241 | 2 | 600ns | my %exports; | ||
242 | my $current_meta_lookup; | ||||
243 | |||||
244 | 2 | 2µs | for my $package ( @{$packages} ) { | ||
245 | 2 | 2µs | my $args = $EXPORT_SPEC{$package} | ||
246 | or die "The $package package does not use Moose::Exporter\n"; | ||||
247 | |||||
248 | 2 | 1µs | $current_meta_lookup = $meta_lookup_override || $args->{meta_lookup}; | ||
249 | 2 | 400ns | $meta_lookup_override = $current_meta_lookup; | ||
250 | |||||
251 | my $meta_lookup = $current_meta_lookup | ||||
252 | 6 | 14µs | 4 | 16µs | # spent 39µs (23+16) within Moose::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm:252] which was called 4 times, avg 10µs/call:
# 4 times (23µs+16µs) by Moose::has at line 418, avg 10µs/call # spent 16µs making 4 calls to Class::MOP::class_of, avg 4µs/call |
253 | |||||
254 | 2 | 4µs | for my $name ( @{ $args->{with_meta} } ) { | ||
255 | 8 | 5µs | 8 | 12µs | my $sub = $class->_sub_from_package( $package, $name ) # spent 12µs making 8 calls to Moose::Exporter::_sub_from_package, avg 2µs/call |
256 | or next; | ||||
257 | |||||
258 | 8 | 2µs | my $fq_name = $package . '::' . $name; | ||
259 | |||||
260 | $exports{$name} = $class->_make_wrapped_sub_with_meta( | ||||
261 | $fq_name, | ||||
262 | $sub, | ||||
263 | $export_recorder, | ||||
264 | $meta_lookup, | ||||
265 | 8 | 13µs | 8 | 12µs | ) unless exists $exports{$name}; # spent 12µs making 8 calls to Moose::Exporter::_make_wrapped_sub_with_meta, avg 1µs/call |
266 | } | ||||
267 | |||||
268 | 2 | 3µs | for my $name ( @{ $args->{with_caller} } ) { | ||
269 | my $sub = $class->_sub_from_package( $package, $name ) | ||||
270 | or next; | ||||
271 | |||||
272 | my $fq_name = $package . '::' . $name; | ||||
273 | |||||
274 | $exports{$name} = $class->_make_wrapped_sub( | ||||
275 | $fq_name, | ||||
276 | $sub, | ||||
277 | $export_recorder, | ||||
278 | ) unless exists $exports{$name}; | ||||
279 | } | ||||
280 | |||||
281 | my @extra_exports = $class->_parse_trait_aliases( | ||||
282 | $package, $args->{trait_aliases}, | ||||
283 | 2 | 5µs | 2 | 7µs | ); # spent 7µs making 2 calls to Moose::Exporter::_parse_trait_aliases, avg 4µs/call |
284 | 2 | 3µs | for my $name ( @{ $args->{as_is} }, @extra_exports ) { | ||
285 | 22 | 2µs | my ( $sub, $coderef_name ); | ||
286 | |||||
287 | 22 | 32µs | 22 | 7µs | if ( ref $name ) { # spent 7µs making 22 calls to Moose::Exporter::CORE:match, avg 314ns/call |
288 | $sub = $name; | ||||
289 | |||||
290 | my $coderef_pkg; | ||||
291 | ( $coderef_pkg, $coderef_name ) | ||||
292 | = Class::MOP::get_code_info($name); | ||||
293 | |||||
294 | if ( $coderef_pkg ne $package ) { | ||||
295 | $is_reexport->{$coderef_name} = 1; | ||||
296 | } | ||||
297 | } | ||||
298 | elsif ( $name =~ /^(.*)::([^:]+)$/ ) { | ||||
299 | 2 | 4µs | 2 | 3µs | $sub = $class->_sub_from_package( "$1", "$2" ) # spent 3µs making 2 calls to Moose::Exporter::_sub_from_package, avg 2µs/call |
300 | or next; | ||||
301 | |||||
302 | 2 | 600ns | $coderef_name = "$2"; | ||
303 | |||||
304 | 2 | 2µs | if ( $1 ne $package ) { | ||
305 | $is_reexport->{$coderef_name} = 1; | ||||
306 | } | ||||
307 | } | ||||
308 | else { | ||||
309 | 20 | 13µs | 20 | 35µs | $sub = $class->_sub_from_package( $package, $name ) # spent 35µs making 20 calls to Moose::Exporter::_sub_from_package, avg 2µs/call |
310 | or next; | ||||
311 | |||||
312 | 20 | 3µs | $coderef_name = $name; | ||
313 | } | ||||
314 | |||||
315 | 22 | 12µs | $export_recorder->{$sub} = 1; | ||
316 | |||||
317 | 22 | 25µs | # spent 21µs within Moose::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm:317] which was called 22 times, avg 955ns/call:
# 22 times (21µs+0s) by Sub::Exporter::default_generator at line 420 of Sub/Exporter.pm, avg 955ns/call | ||
318 | 22 | 24µs | unless exists $exports{$coderef_name}; | ||
319 | } | ||||
320 | } | ||||
321 | |||||
322 | 2 | 5µs | return \%exports; | ||
323 | } | ||||
324 | |||||
325 | # spent 51µs within Moose::Exporter::_sub_from_package which was called 30 times, avg 2µs/call:
# 20 times (35µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 309, avg 2µs/call
# 8 times (12µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 255, avg 2µs/call
# 2 times (3µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 299, avg 2µs/call | ||||
326 | 30 | 3µs | my $sclass = shift; | ||
327 | 30 | 4µs | my $package = shift; | ||
328 | 30 | 3µs | my $name = shift; | ||
329 | |||||
330 | 30 | 6µs | my $sub = do { | ||
331 | 2 | 913µs | 2 | 23µs | # spent 15µs (7+8) within Moose::Exporter::BEGIN@331 which was called:
# once (7µs+8µs) by Moose::BEGIN@15 at line 331 # spent 15µs making 1 call to Moose::Exporter::BEGIN@331
# spent 8µs making 1 call to strict::unimport |
332 | 30 | 19µs | \&{ $package . '::' . $name }; | ||
333 | }; | ||||
334 | |||||
335 | 30 | 34µs | return $sub if defined &$sub; | ||
336 | |||||
337 | Carp::cluck "Trying to export undefined sub ${package}::${name}"; | ||||
338 | |||||
339 | return; | ||||
340 | } | ||||
341 | |||||
342 | our $CALLER; | ||||
343 | |||||
344 | sub _make_wrapped_sub { | ||||
345 | my $self = shift; | ||||
346 | my $fq_name = shift; | ||||
347 | my $sub = shift; | ||||
348 | my $export_recorder = shift; | ||||
349 | |||||
350 | # We need to set the package at import time, so that when | ||||
351 | # package Foo imports has(), we capture "Foo" as the | ||||
352 | # package. This lets other packages call Foo::has() and get | ||||
353 | # the right package. This is done for backwards compatibility | ||||
354 | # with existing production code, not because this is a good | ||||
355 | # idea ;) | ||||
356 | return sub { | ||||
357 | my $caller = $CALLER; | ||||
358 | |||||
359 | my $wrapper = $self->_curry_wrapper( $sub, $fq_name, $caller ); | ||||
360 | |||||
361 | my $sub = subname( $fq_name => $wrapper ); | ||||
362 | |||||
363 | $export_recorder->{$sub} = 1; | ||||
364 | |||||
365 | return $sub; | ||||
366 | }; | ||||
367 | } | ||||
368 | |||||
369 | # spent 12µs within Moose::Exporter::_make_wrapped_sub_with_meta which was called 8 times, avg 1µs/call:
# 8 times (12µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 265, avg 1µs/call | ||||
370 | 8 | 1µs | my $self = shift; | ||
371 | 8 | 1µs | my $fq_name = shift; | ||
372 | 8 | 700ns | my $sub = shift; | ||
373 | 8 | 800ns | my $export_recorder = shift; | ||
374 | 8 | 700ns | my $meta_lookup = shift; | ||
375 | |||||
376 | # spent 79µs (39+39) within Moose::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm:389] which was called 8 times, avg 10µs/call:
# 8 times (39µs+39µs) by Sub::Exporter::default_generator at line 420 of Sub/Exporter.pm, avg 10µs/call | ||||
377 | 8 | 1µs | my $caller = $CALLER; | ||
378 | |||||
379 | 8 | 7µs | 8 | 22µs | my $wrapper = $self->_late_curry_wrapper( # spent 22µs making 8 calls to Moose::Exporter::_late_curry_wrapper, avg 3µs/call |
380 | $sub, $fq_name, | ||||
381 | $meta_lookup => $caller | ||||
382 | ); | ||||
383 | |||||
384 | 8 | 27µs | 8 | 18µs | my $sub = subname( $fq_name => $wrapper ); # spent 18µs making 8 calls to Sub::Name::subname, avg 2µs/call |
385 | |||||
386 | 8 | 6µs | $export_recorder->{$sub} = 1; | ||
387 | |||||
388 | 8 | 10µs | return $sub; | ||
389 | 8 | 12µs | }; | ||
390 | } | ||||
391 | |||||
392 | sub _curry_wrapper { | ||||
393 | my $class = shift; | ||||
394 | my $sub = shift; | ||||
395 | my $fq_name = shift; | ||||
396 | my @extra = @_; | ||||
397 | |||||
398 | my $wrapper = sub { $sub->( @extra, @_ ) }; | ||||
399 | if ( my $proto = prototype $sub ) { | ||||
400 | |||||
401 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
402 | # ignore the fact that we're passing "private variables" | ||||
403 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
404 | } | ||||
405 | return $wrapper; | ||||
406 | } | ||||
407 | |||||
408 | # spent 22µs within Moose::Exporter::_late_curry_wrapper which was called 8 times, avg 3µs/call:
# 8 times (22µs+0s) by Moose::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm:389] at line 379, avg 3µs/call | ||||
409 | 8 | 1µs | my $class = shift; | ||
410 | 8 | 2µs | my $sub = shift; | ||
411 | 8 | 3µs | my $fq_name = shift; | ||
412 | 8 | 700ns | my $extra = shift; | ||
413 | 8 | 2µs | my @ex_args = @_; | ||
414 | |||||
415 | # spent 26.4ms (71µs+26.3) within Moose::has which was called 8 times, avg 3.30ms/call:
# 4 times (52µs+13.1ms) by Moose::has at line 419, avg 3.29ms/call
# once (6µs+7.29ms) by BenchmarkAnything::Storage::Frontend::Lib::BEGIN@280 at line 13 of DBIx/MultiStatementDo.pm
# once (6µs+3.05ms) by BenchmarkAnything::Storage::Frontend::Lib::BEGIN@280 at line 19 of DBIx/MultiStatementDo.pm
# once (4µs+1.84ms) by BenchmarkAnything::Storage::Frontend::Lib::BEGIN@280 at line 37 of DBIx/MultiStatementDo.pm
# once (3µs+1.04ms) by BenchmarkAnything::Storage::Frontend::Lib::BEGIN@280 at line 39 of DBIx/MultiStatementDo.pm | ||||
416 | |||||
417 | # resolve curried arguments at runtime via this closure | ||||
418 | 4 | 19µs | 4 | 39µs | my @curry = ( $extra->(@ex_args) ); # spent 39µs making 4 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:252], avg 10µs/call |
419 | 4 | 13µs | 4 | 13.2ms | return $sub->( @curry, @_ ); # spent 13.2ms making 4 calls to Moose::has, avg 3.29ms/call |
420 | 8 | 6µs | }; | ||
421 | |||||
422 | 8 | 2µs | if ( my $proto = prototype $sub ) { | ||
423 | |||||
424 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
425 | # ignore the fact that we're passing "private variables" | ||||
426 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
427 | } | ||||
428 | 8 | 12µs | return $wrapper; | ||
429 | } | ||||
430 | |||||
431 | # spent 9µs within Moose::Exporter::_make_import_sub which was called 2 times, avg 5µs/call:
# 2 times (9µs+0s) by Moose::Exporter::build_import_methods at line 62, avg 5µs/call | ||||
432 | 2 | 400ns | shift; | ||
433 | 2 | 600ns | my $exporting_package = shift; | ||
434 | 2 | 600ns | my $exporter = shift; | ||
435 | 2 | 400ns | my $exports_from = shift; | ||
436 | 2 | 600ns | my $is_reexport = shift; | ||
437 | 2 | 500ns | my $meta_lookup = shift; | ||
438 | |||||
439 | return sub { | ||||
440 | |||||
441 | # I think we could use Sub::Exporter's collector feature | ||||
442 | # to do this, but that would be rather gross, since that | ||||
443 | # feature isn't really designed to return a value to the | ||||
444 | # caller of the exporter sub. | ||||
445 | # | ||||
446 | # Also, this makes sure we preserve backwards compat for | ||||
447 | # _get_caller, so it always sees the arguments in the | ||||
448 | # expected order. | ||||
449 | 2 | 400ns | my $traits; | ||
450 | 2 | 6µs | 2 | 29µs | ( $traits, @_ ) = _strip_traits(@_); # spent 29µs making 2 calls to Moose::Exporter::_strip_traits, avg 14µs/call |
451 | |||||
452 | 2 | 500ns | my $metaclass; | ||
453 | 2 | 5µs | 2 | 11µs | ( $metaclass, @_ ) = _strip_metaclass(@_); # spent 11µs making 2 calls to Moose::Exporter::_strip_metaclass, avg 6µs/call |
454 | 2 | 500ns | $metaclass | ||
455 | = Moose::Util::resolve_metaclass_alias( 'Class' => $metaclass ) | ||||
456 | if defined $metaclass && length $metaclass; | ||||
457 | |||||
458 | 2 | 300ns | my $meta_name; | ||
459 | 2 | 5µs | 2 | 11µs | ( $meta_name, @_ ) = _strip_meta_name(@_); # spent 11µs making 2 calls to Moose::Exporter::_strip_meta_name, avg 5µs/call |
460 | |||||
461 | # Normally we could look at $_[0], but in some weird cases | ||||
462 | # (involving goto &Moose::import), $_[0] ends as something | ||||
463 | # else (like Squirrel). | ||||
464 | 2 | 700ns | my $class = $exporting_package; | ||
465 | |||||
466 | 2 | 3µs | 2 | 6µs | $CALLER = _get_caller(@_); # spent 6µs making 2 calls to Moose::Exporter::_get_caller, avg 3µs/call |
467 | |||||
468 | # this works because both pragmas set $^H (see perldoc | ||||
469 | # perlvar) which affects the current compilation - | ||||
470 | # i.e. the file who use'd us - which is why we don't need | ||||
471 | # to do anything special to make it affect that file | ||||
472 | # rather than this one (which is already compiled) | ||||
473 | |||||
474 | 2 | 4µs | 2 | 4µs | strict->import; # spent 4µs making 2 calls to strict::import, avg 2µs/call |
475 | 2 | 3µs | 2 | 14µs | warnings->import; # spent 14µs making 2 calls to warnings::import, avg 7µs/call |
476 | |||||
477 | 2 | 400ns | my $did_init_meta; | ||
478 | 4 | 18µs | 2 | 4µs | for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) { # spent 4µs making 2 calls to UNIVERSAL::can, avg 2µs/call |
479 | |||||
480 | # init_meta can apply a role, which when loaded uses | ||||
481 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
482 | # to protect against that. | ||||
483 | 1 | 400ns | local $CALLER = $CALLER; | ||
484 | 1 | 2µs | 1 | 1.83ms | $c->init_meta( # spent 1.83ms making 1 call to Moose::init_meta |
485 | for_class => $CALLER, | ||||
486 | metaclass => $metaclass, | ||||
487 | meta_name => $meta_name, | ||||
488 | ); | ||||
489 | 1 | 700ns | $did_init_meta = 1; | ||
490 | } | ||||
491 | |||||
492 | { | ||||
493 | # The metaroles will use Moose::Role, which in turn uses | ||||
494 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
495 | # to protect against that. | ||||
496 | 4 | 3µs | local $CALLER = $CALLER; | ||
497 | 2 | 4µs | 2 | 64µs | _apply_metaroles( # spent 64µs making 2 calls to Moose::Exporter::_apply_metaroles, avg 32µs/call |
498 | $CALLER, | ||||
499 | [$class, @$exports_from], | ||||
500 | $meta_lookup | ||||
501 | ); | ||||
502 | } | ||||
503 | |||||
504 | 2 | 2µs | if ( $did_init_meta && @{$traits} ) { | ||
505 | |||||
506 | # The traits will use Moose::Role, which in turn uses | ||||
507 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
508 | # to protect against that. | ||||
509 | local $CALLER = $CALLER; | ||||
510 | _apply_meta_traits( $CALLER, $traits, $meta_lookup ); | ||||
511 | } | ||||
512 | elsif ( @{$traits} ) { | ||||
513 | throw_exception( ClassDoesNotHaveInitMeta => class_name => $class, | ||||
514 | traits => $traits | ||||
515 | ); | ||||
516 | } | ||||
517 | |||||
518 | 2 | 1µs | my ( undef, @args ) = @_; | ||
519 | 2 | 1µs | my $extra = shift @args if ref $args[0] eq 'HASH'; | ||
520 | |||||
521 | 2 | 700ns | $extra ||= {}; | ||
522 | 2 | 1µs | if ( !$extra->{into} ) { | ||
523 | 2 | 1µs | $extra->{into_level} ||= 0; | ||
524 | 2 | 600ns | $extra->{into_level}++; | ||
525 | } | ||||
526 | |||||
527 | 2 | 10µs | 2 | 1.28ms | $class->$exporter( $extra, @args ); # spent 1.28ms making 2 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:337], avg 641µs/call |
528 | 2 | 7µs | }; | ||
529 | } | ||||
530 | |||||
531 | # spent 29µs (17+12) within Moose::Exporter::_strip_traits which was called 2 times, avg 14µs/call:
# 2 times (17µs+12µs) by Moose::Util::TypeConstraints::import or Moose::import at line 450, avg 14µs/call | ||||
532 | 4 | 23µs | 2 | 12µs | my $idx = first_index { ( $_ || '' ) eq '-traits' } @_; # spent 12µs making 2 calls to List::MoreUtils::firstidx, avg 6µs/call |
533 | |||||
534 | 2 | 8µs | return ( [], @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
535 | |||||
536 | my $traits = $_[ $idx + 1 ]; | ||||
537 | |||||
538 | splice @_, $idx, 2; | ||||
539 | |||||
540 | $traits = [$traits] unless ref $traits; | ||||
541 | |||||
542 | return ( $traits, @_ ); | ||||
543 | } | ||||
544 | |||||
545 | # spent 11µs (9+2) within Moose::Exporter::_strip_metaclass which was called 2 times, avg 6µs/call:
# 2 times (9µs+2µs) by Moose::Util::TypeConstraints::import or Moose::import at line 453, avg 6µs/call | ||||
546 | 4 | 8µs | 2 | 2µs | my $idx = first_index { ( $_ || '' ) eq '-metaclass' } @_; # spent 2µs making 2 calls to List::MoreUtils::firstidx, avg 1µs/call |
547 | |||||
548 | 2 | 4µs | return ( undef, @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
549 | |||||
550 | my $metaclass = $_[ $idx + 1 ]; | ||||
551 | |||||
552 | splice @_, $idx, 2; | ||||
553 | |||||
554 | return ( $metaclass, @_ ); | ||||
555 | } | ||||
556 | |||||
557 | # spent 11µs (9+2) within Moose::Exporter::_strip_meta_name which was called 2 times, avg 5µs/call:
# 2 times (9µs+2µs) by Moose::Util::TypeConstraints::import or Moose::import at line 459, avg 5µs/call | ||||
558 | 4 | 7µs | 2 | 2µs | my $idx = first_index { ( $_ || '' ) eq '-meta_name' } @_; # spent 2µs making 2 calls to List::MoreUtils::firstidx, avg 800ns/call |
559 | |||||
560 | 2 | 4µs | return ( 'meta', @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
561 | |||||
562 | my $meta_name = $_[ $idx + 1 ]; | ||||
563 | |||||
564 | splice @_, $idx, 2; | ||||
565 | |||||
566 | return ( $meta_name, @_ ); | ||||
567 | } | ||||
568 | |||||
569 | # spent 64µs (18+46) within Moose::Exporter::_apply_metaroles which was called 2 times, avg 32µs/call:
# 2 times (18µs+46µs) by Moose::Util::TypeConstraints::import or Moose::import at line 497, avg 32µs/call | ||||
570 | 2 | 1µs | my ($class, $exports_from, $meta_lookup) = @_; | ||
571 | |||||
572 | 2 | 3µs | 2 | 32µs | my $metaroles = _collect_metaroles($exports_from); # spent 32µs making 2 calls to Moose::Exporter::_collect_metaroles, avg 16µs/call |
573 | 2 | 800ns | my $base_class_roles = delete $metaroles->{base_class_roles}; | ||
574 | |||||
575 | 2 | 4µs | 2 | 13µs | my $meta = $meta_lookup->($class); # spent 13µs making 2 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:39], avg 6µs/call |
576 | # for instance, Moose.pm uses Moose::Util::TypeConstraints | ||||
577 | 2 | 3µs | return unless $meta; | ||
578 | |||||
579 | 1 | 600ns | Moose::Util::MetaRole::apply_metaroles( | ||
580 | for => $meta, | ||||
581 | %$metaroles, | ||||
582 | ) if keys %$metaroles; | ||||
583 | |||||
584 | 1 | 4µs | 1 | 500ns | Moose::Util::MetaRole::apply_base_class_roles( # spent 500ns making 1 call to UNIVERSAL::isa |
585 | for => $meta, | ||||
586 | roles => $base_class_roles, | ||||
587 | ) if $meta->isa('Class::MOP::Class') | ||||
588 | && $base_class_roles && @$base_class_roles; | ||||
589 | } | ||||
590 | |||||
591 | # spent 32µs within Moose::Exporter::_collect_metaroles which was called 2 times, avg 16µs/call:
# 2 times (32µs+0s) by Moose::Exporter::_apply_metaroles at line 572, avg 16µs/call | ||||
592 | 2 | 700ns | my ($exports_from) = @_; | ||
593 | |||||
594 | 2 | 12µs | my @old_style_role_types = map { "${_}_roles" } qw( | ||
595 | metaclass | ||||
596 | attribute_metaclass | ||||
597 | method_metaclass | ||||
598 | wrapped_method_metaclass | ||||
599 | instance_metaclass | ||||
600 | constructor_class | ||||
601 | destructor_class | ||||
602 | error_class | ||||
603 | ); | ||||
604 | |||||
605 | 2 | 600ns | my %class_metaroles; | ||
606 | my %role_metaroles; | ||||
607 | my @base_class_roles; | ||||
608 | my %old_style_roles; | ||||
609 | |||||
610 | 2 | 2µs | for my $exporter (@$exports_from) { | ||
611 | 2 | 2µs | my $data = $EXPORT_SPEC{$exporter}; | ||
612 | |||||
613 | 2 | 1µs | if (exists $data->{class_metaroles}) { | ||
614 | for my $type (keys %{ $data->{class_metaroles} }) { | ||||
615 | push @{ $class_metaroles{$type} ||= [] }, | ||||
616 | @{ $data->{class_metaroles}{$type} }; | ||||
617 | } | ||||
618 | } | ||||
619 | |||||
620 | 2 | 600ns | if (exists $data->{role_metaroles}) { | ||
621 | for my $type (keys %{ $data->{role_metaroles} }) { | ||||
622 | push @{ $role_metaroles{$type} ||= [] }, | ||||
623 | @{ $data->{role_metaroles}{$type} }; | ||||
624 | } | ||||
625 | } | ||||
626 | |||||
627 | 2 | 700ns | if (exists $data->{base_class_roles}) { | ||
628 | push @base_class_roles, @{ $data->{base_class_roles} }; | ||||
629 | } | ||||
630 | |||||
631 | 2 | 2µs | for my $type (@old_style_role_types) { | ||
632 | 16 | 5µs | if (exists $data->{$type}) { | ||
633 | push @{ $old_style_roles{$type} ||= [] }, | ||||
634 | @{ $data->{$type} }; | ||||
635 | } | ||||
636 | } | ||||
637 | } | ||||
638 | |||||
639 | return { | ||||
640 | 2 | 8µs | (keys(%class_metaroles) | ||
641 | ? (class_metaroles => \%class_metaroles) | ||||
642 | : ()), | ||||
643 | (keys(%role_metaroles) | ||||
644 | ? (role_metaroles => \%role_metaroles) | ||||
645 | : ()), | ||||
646 | (@base_class_roles | ||||
647 | ? (base_class_roles => \@base_class_roles) | ||||
648 | : ()), | ||||
649 | %old_style_roles, | ||||
650 | }; | ||||
651 | } | ||||
652 | |||||
653 | sub _apply_meta_traits { | ||||
654 | my ( $class, $traits, $meta_lookup ) = @_; | ||||
655 | |||||
656 | return unless @{$traits}; | ||||
657 | |||||
658 | my $meta = $meta_lookup->($class); | ||||
659 | |||||
660 | my $type = $meta->isa('Moose::Meta::Role') ? 'Role' | ||||
661 | : $meta->isa('Class::MOP::Class') ? 'Class' | ||||
662 | : confess('Cannot determine metaclass type for ' | ||||
663 | . 'trait application. Meta isa ' | ||||
664 | . ref $meta); | ||||
665 | |||||
666 | my @resolved_traits = map { | ||||
667 | ref $_ | ||||
668 | ? $_ | ||||
669 | : Moose::Util::resolve_metatrait_alias( $type => $_ ) | ||||
670 | } @$traits; | ||||
671 | |||||
672 | return unless @resolved_traits; | ||||
673 | |||||
674 | my %args = ( for => $class ); | ||||
675 | |||||
676 | if ( $meta->isa('Moose::Meta::Role') ) { | ||||
677 | $args{role_metaroles} = { role => \@resolved_traits }; | ||||
678 | } | ||||
679 | else { | ||||
680 | $args{class_metaroles} = { class => \@resolved_traits }; | ||||
681 | } | ||||
682 | |||||
683 | Moose::Util::MetaRole::apply_metaroles(%args); | ||||
684 | } | ||||
685 | |||||
686 | # spent 6µs within Moose::Exporter::_get_caller which was called 2 times, avg 3µs/call:
# 2 times (6µs+0s) by Moose::Util::TypeConstraints::import or Moose::import at line 466, avg 3µs/call | ||||
687 | |||||
688 | # 1 extra level because it's called by import so there's a layer | ||||
689 | # of indirection | ||||
690 | 2 | 500ns | my $offset = 1; | ||
691 | |||||
692 | return | ||||
693 | ( ref $_[1] && defined $_[1]->{into} ) ? $_[1]->{into} | ||||
694 | : ( ref $_[1] && defined $_[1]->{into_level} ) | ||||
695 | ? caller( $offset + $_[1]->{into_level} ) | ||||
696 | 2 | 7µs | : caller($offset); | ||
697 | } | ||||
698 | |||||
699 | # spent 9µs within Moose::Exporter::_make_unimport_sub which was called 2 times, avg 5µs/call:
# 2 times (9µs+0s) by Moose::Exporter::build_import_methods at line 70, avg 5µs/call | ||||
700 | 2 | 400ns | shift; | ||
701 | 2 | 400ns | my $exporting_package = shift; | ||
702 | 2 | 1µs | my $exports = shift; | ||
703 | 2 | 700ns | my $export_recorder = shift; | ||
704 | 2 | 300ns | my $is_reexport = shift; | ||
705 | 2 | 400ns | my $meta_lookup = shift; | ||
706 | |||||
707 | return sub { | ||||
708 | 1 | 900ns | my $caller = scalar caller(); | ||
709 | Moose::Exporter->_remove_keywords( | ||||
710 | $caller, | ||||
711 | 1 | 9µs | 1 | 46µs | [ keys %{$exports} ], # spent 46µs making 1 call to Moose::Exporter::_remove_keywords |
712 | $export_recorder, | ||||
713 | $is_reexport, | ||||
714 | ); | ||||
715 | 2 | 8µs | }; | ||
716 | } | ||||
717 | |||||
718 | # spent 46µs (45+900ns) within Moose::Exporter::_remove_keywords which was called:
# once (45µs+900ns) by Moose::unimport at line 711 | ||||
719 | 1 | 300ns | shift; | ||
720 | 1 | 600ns | my $package = shift; | ||
721 | 1 | 400ns | my $keywords = shift; | ||
722 | 1 | 200ns | my $recorded_exports = shift; | ||
723 | 1 | 200ns | my $is_reexport = shift; | ||
724 | |||||
725 | 2 | 38µs | 2 | 25µs | # spent 15µs (6+10) within Moose::Exporter::BEGIN@725 which was called:
# once (6µs+10µs) by Moose::BEGIN@15 at line 725 # spent 15µs making 1 call to Moose::Exporter::BEGIN@725
# spent 10µs making 1 call to strict::unimport |
726 | |||||
727 | 1 | 4µs | foreach my $name ( @{$keywords} ) { | ||
728 | 12 | 8µs | if ( defined &{ $package . '::' . $name } ) { | ||
729 | 12 | 5µs | my $sub = \&{ $package . '::' . $name }; | ||
730 | |||||
731 | # make sure it is from us | ||||
732 | 12 | 3µs | next unless $recorded_exports->{$sub}; | ||
733 | |||||
734 | 12 | 2µs | if ( $is_reexport->{$name} ) { | ||
735 | 2 | 165µs | 2 | 15µs | # spent 10µs (4+5) within Moose::Exporter::BEGIN@735 which was called:
# once (4µs+5µs) by Moose::BEGIN@15 at line 735 # spent 10µs making 1 call to Moose::Exporter::BEGIN@735
# spent 5µs making 1 call to strict::unimport |
736 | next | ||||
737 | unless _export_is_flagged( | ||||
738 | 2 | 8µs | 2 | 900ns | \*{ join q{::} => $package, $name } ); # spent 900ns making 2 calls to Moose::Exporter::_export_is_flagged, avg 450ns/call |
739 | } | ||||
740 | |||||
741 | # and if it is from us, then undef the slot | ||||
742 | 12 | 15µs | delete ${ $package . '::' }{$name}; | ||
743 | } | ||||
744 | } | ||||
745 | } | ||||
746 | |||||
747 | # maintain this for now for backcompat | ||||
748 | # make sure to return a sub to install in the same circumstances as previously | ||||
749 | # but this functionality now happens at the end of ->import | ||||
750 | # spent 22µs within Moose::Exporter::_make_init_meta which was called 2 times, avg 11µs/call:
# 2 times (22µs+0s) by Moose::Exporter::build_import_methods at line 78, avg 11µs/call | ||||
751 | 2 | 300ns | shift; | ||
752 | 2 | 500ns | my $class = shift; | ||
753 | 2 | 500ns | my $args = shift; | ||
754 | 2 | 200ns | my $meta_lookup = shift; | ||
755 | |||||
756 | 2 | 300ns | my %old_style_roles; | ||
757 | 2 | 8µs | for my $role ( | ||
758 | map {"${_}_roles"} | ||||
759 | qw( | ||||
760 | metaclass | ||||
761 | attribute_metaclass | ||||
762 | method_metaclass | ||||
763 | wrapped_method_metaclass | ||||
764 | instance_metaclass | ||||
765 | constructor_class | ||||
766 | destructor_class | ||||
767 | error_class | ||||
768 | ) | ||||
769 | ) { | ||||
770 | $old_style_roles{$role} = $args->{$role} | ||||
771 | 16 | 3µs | if exists $args->{$role}; | ||
772 | } | ||||
773 | |||||
774 | 2 | 300ns | my %base_class_roles; | ||
775 | %base_class_roles = ( roles => $args->{base_class_roles} ) | ||||
776 | 2 | 500ns | if exists $args->{base_class_roles}; | ||
777 | |||||
778 | my %new_style_roles = map { $_ => $args->{$_} } | ||||
779 | 2 | 3µs | grep { exists $args->{$_} } qw( class_metaroles role_metaroles ); | ||
780 | |||||
781 | 2 | 5µs | return unless %new_style_roles || %old_style_roles || %base_class_roles; | ||
782 | |||||
783 | return sub { | ||||
784 | shift; | ||||
785 | my %opts = @_; | ||||
786 | $meta_lookup->($opts{for_class}); | ||||
787 | }; | ||||
788 | } | ||||
789 | |||||
790 | # spent 27µs (13+14) within Moose::Exporter::import which was called 2 times, avg 13µs/call:
# once (7µs+9µs) by Moose::BEGIN@15 at line 15 of Moose.pm
# once (6µs+4µs) by Moose::Util::TypeConstraints::BEGIN@6 at line 6 of Moose/Util/TypeConstraints.pm | ||||
791 | 2 | 3µs | 2 | 3µs | strict->import; # spent 3µs making 2 calls to strict::import, avg 2µs/call |
792 | 2 | 6µs | 2 | 10µs | warnings->import; # spent 10µs making 2 calls to warnings::import, avg 5µs/call |
793 | } | ||||
794 | |||||
795 | 1 | 3µs | 1; | ||
796 | |||||
797 | # ABSTRACT: make an import() and unimport() just like Moose.pm | ||||
798 | |||||
799 | __END__ | ||||
# spent 7µs within Moose::Exporter::CORE:match which was called 22 times, avg 314ns/call:
# 22 times (7µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 287, avg 314ns/call | |||||
# spent 900ns within Moose::Exporter::_export_is_flagged which was called 2 times, avg 450ns/call:
# 2 times (900ns+0s) by Moose::Exporter::_remove_keywords at line 738, avg 450ns/call | |||||
# spent 2µs within Moose::Exporter::_flag_as_reexport which was called 2 times, avg 1µs/call:
# 2 times (2µs+0s) by Moose::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Exporter.pm:140] at line 138, avg 1µs/call |